Wordhop - A Toolkit For Human + AI Conversational Experiences
For Chatbots Built in Ruby
Bots can help your business respond faster and scale your service delivery at a lower cost, but bots can't empathize like humans, or solve overly complex customer problems. With Wordhop, you can monitor your bots for communication problems and take over live to engage your customers.
It includes a number of smart alerts out of the box, and you can create your own alerts. You can resume automated messaging manually, or if you stop engaging your user, the bot will automatically resume. This is how we see humans and AI collaborating on customer service in the messaging era:
![Solution](https://cloud.githubusercontent.com/assets/7429980/22609969/491afe58-ea31-11e6-8928-27e1a1f1d6bd.png)
You can integrate Wordhop in minutes and it begins working immediately, enabling you to deliver exceptional human + AI conversational experiences.
This module has been tested with Messenger, Slack, Skype, and Microsoft Webchat. Please see our examples.
It supports bot developers working in Node, Python and Ruby.
What you can do with Wordhop:
You can view a full list of features at (https://www.wordhop.io). It's core purpose can be explained with this single GIF
![Takeover](https://cloud.githubusercontent.com/assets/7429980/22609935/22e39740-ea31-11e6-8286-e5a3ae545565.gif)
What you need to get started:
Operational Dependencies:
- You'll need an API key from Wordhop and for each Chatbot a Bot Token. You can get both of those (free) when you add Wordhop to Slack and through a conversation with Wordhop.
- If you're building a Messenger Chatbot, you'll need to setup a Facebook App, Facebook Page, get the Page Access Token from Facebook and link the Facebook App to the Facebook Page for Wordhop to work.
Installation
$ gem install wordhop
Usage
Set your environmental variables for WORDHOP_API_KEY
, WORDHOP_CLIENT_KEY
, ACCESS_TOKEN
.
$ export WORDHOP_API_KEY=xxxxxxxxxxxxxxxxxxxx
$ export WORDHOP_CLIENT_KEY=xxxxxxxxxxxxxxxxxxxx
$ export ACCESS_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Add the Wordhop class to your code and set the required parameter values.
require 'wordhop'
Wordhop.apikey = ENV['WORDHOP_API_KEY']
Wordhop.clientkey = ENV['WORDHOP_CLIENT_KEY']
Wordhop.platform = "messenger"
Wordhop.token = ENV['ACCESS_TOKEN']
Incoming Message Schema:
Throughout this documentation, you will see references to incomingMessage
. Depending on whether you have a Messenger or Slack bot, the schema will be different. The value of incomingMessage
should be equal to the message you receive directly from either the Messenger webhook response, or from the Slack RTM event response.
{
"type": "message",
"channel": "D024BE91L",
"user": "U2147483697",
"text": "Hello world",
"ts": "1355517523.000005"
}
{
"sender":{
"id":"USER_ID"
},
"recipient":{
"id":"PAGE_ID"
},
"timestamp":1458692752478,
"message":{
"mid":"mid.1457764197618:41d102a3e1ae206a38",
"seq":73,
"text":"hello, world!",
"quick_reply": {
"payload": "DEVELOPER_DEFINED_PAYLOAD"
}
}
}
Outgoing Message Schema:
Throughout this documentation, you will see references to outgoingMessage
. Depending on whether you have a Messenger or Slack bot, the schema, as defined by each platform, will be different. Every time you track an outgoing message, the schema requirements match the respective platform.
{
"channel": "C024BE91L",
"text": "Hello world"
}
{
"recipient":{
"id":"USER_ID"
},
"message":{
"text":"hello, world!"
}
}
Tracking received messages:
When your bot receives an incoming message, you'll need to log the data with Wordhop by calling to wordhop.hopIn
.
Note: Wordhop can pause your bot so that it doesn't auto response while a human has taken over. The server response from your hopIn
request will pass the paused
state. Use that to stop your bot from responding to an incoming message. Here is an example:
hopInResponse = Wordhop.hopIn(incomingMessage)
if hopInResponse['paused'] != true
...
Tracking sent messages:
Each time your bot sends a message, make sure to log that with Wordhop by calling to wordhop.hopOut
. Here is an example of a function that we're calling sendIt
that tracks an outgoing message and at the same time, has the bot say the message:
def sendIt(channel, text)
outgoingMessage = {recipient: {id: channel},message: {text: text}}
Wordhop.hopOut(outgoingMessage)
client.say({'text': text, 'channel': channel})
...
Log Unknown Intents:
Find the spot in your code your bot processes incoming messages it does not understand. Within that block of code, call to wordhop.logUnkownIntent
to capture these conversational ‘dead-ends’. Here's an example:
sendIt(recipient_id, 'Huh?')
Wordhop.logUnknownIntent(incomingMessage)
Dial 0 to Speak With a Live Human Being:
Wordhop can trigger alerts to suggest when a human should take over for your Chatbot. To enable this, create an intent such as when a customer explicitly requests live assistance, and then include the following lines of code where your bot listens for this intent:
if text == 'help'
sendIt(recipient_id, 'Hang tight. Let me see what I can do.')
Wordhop.assistanceRequested(incomingMessage);
Human Take Over:
To enable the ability to have a human take over your bot, add the following code:
Wordhop.on :'chat response' do |data|
text = data['text']
channel = data['channel']
client.say({'text': text, 'channel': channel})
end
Go back to Slack and wait for alerts. That's it!
Be sure to check out our examples.
Looking for something we don't yet support?