Creating a Facebook Chatbot: Part 2/2
What do we already know?
Having mastered the basics and created a functional chatbot, now we're going to explore further. We'll now be learning about "AI", user input, and live chat. AI and user input can enhance the interaction of the bot, where live chat allows you to step in and take some more control over that interaction personally (with the help of the chatbot.)
So far, we've been working in the "Automate" section. Let's move to the "Set up AI" section. You can find this here:
This is where we can configure automatic responses to user input. This is a fairly simple process: you'll add a Rule, predict the user behavior with keywords and keyphrases, and return either a Text (a simple message) or a Block. Let's use this to give users the hours of business of our fictional restaurant if they ask.
In the left text box, let's put some phrases and keywords that might be useful. For example, "hours", "when are you open", etc. Use the Enter or Return key to separate phrases.
In the right text box, we'll select Text and enter the message. Here's what this looks like:
Now, let's try this out in Messenger: (NOTE: this is not our most current bot version. The Pitch block is lacking. This is because I already used this Facebook account for testing, earlier in the process. My bot DOES work, but it's skipping the Pitch block because that wasn't implemented the first time I messaged through this account. Be aware of this as you do your own testing!)
What if we instead use "AI" to direct users to a block? Let's do that now. You should remember how to make a block and set it up- if not, refer to What do we already know? and check the previous article.
Call your block Drink Menu. First, we'll add a Typing. Then, we'll add a Text- but this time, we're not going to have any buttons. We're going to look at Quick Reply instead.
Quick Reply does the same as buttons, with the added ability to process user input. We're going to bring up this block when the user asks what drinks are available. Normally, we would use this to make a block with buttons, where the user could click either milk, soft drinks, or juice. We're going to have these three buttons still, through Quick Reply, but this time, the user can also TYPE what they are interested in... even if it's NOT one of the three options!
To this end, let's make four blocks- Milk, Soft Drinks, Juice, and Other Drinks. Once you've made those, head back to Drink Menu and add a Quick Reply under the Typing and Text.
Two important points:
- Buttons under text move vertically, so you go DOWN to add a new button. Buttons with Quick Reply move horizontally, so you go RIGHT to add a new button.
- You can have MORE than three buttons with Quick Reply.
Other than that, it's exactly the same as adding buttons under Text. You should have something like this:
Make sure that the "Text replies..." slider is turned on.
Now, let's make sure that that if a user wants to know about drinks, this Drink Menu block comes up. Go back to Set Up AI, and Add a New Rule.
Something simple like this is usually good enough. You don't have to go into exhausting detail of what a user might say exactly. 3 or 4 phrases should be plenty in most general scenarios. However, it's not perfect, and it's definitely not actually artificial intelligence. It seems to struggle with simple concepts such as "have" and "got" being synonyms, and just grammar disparities in general.
A good workflow I've found is to use AI to get into a block from a user input, but then use buttons to move forward from that block. In other words, let the user's input decide WHAT block gets shown, and then use pre-defined buttons to continue the flow. This is a safe way to make sure the user gets messages back.
Let's see what this looks like, before I answer:
What happens when the bot doesn't understand?
In a perfect world, where Chatfuel actually used "artificial intelligence", this would not happen. In actuality, Chatfuel seems to just use a fairly inflexible keyword search, and it's actually surprisingly difficult to interpret a user message of more than one or two words. Also, if a user misspells something, Chatfuel can't understand.
When this happens, the default reaction is for Chatfuel to simply ignore the message. The bot doesn't even "read" the message, it just leaves the user staring at the "Delivered" icon for the rest of eternity. This is an incredibly petty way to handle miscommunication, so let's fix that!
What we're going to do is make it so the bot diverts the user to Live Chat when it doesn't understand something. It's a crude workaround, I'll admit, but there isn't a better input interpreter currently available for free.
Go back to "Automate", where you can find your blocks, and go to the Default Answer block. This is the block that is sent when input isn't understood. Because it's currently empty, your bot ignores input it doesn't understand.
First, add a Text element to let the user know they are being transferred to a human. Then, we'll do the transfer. To find Live Chat, you need to click on the More button in Elements, and scroll to here:
Once you add this, you don't need to change any settings. It is ready to go, right out of the box. The whole block will now look like this:
Let's see how this works in Messenger:
Perfect! Now all we need to know is who is the manager, and how do they know they've been connected in this way?
If you go back to your Chatfuel dashboard, you'll notice something different. In fact, you'll notice something different in the tab name- there's now a (1) in front of "Chatfuel Dashboard". Looking at the dashboard, you'll see this:
That red notification lets you know that you have someone wanting to talk to you, which you can do through the dashboard. Just click on Live Chat, and you'll see a chat under the Active tab. You can tell if someone is on live chat or not by the bottom right corner. This is what you'll see on a live chat:
Whereas this is what you see on a chatbot conversation:
You probably can tell that you can start live chat with anyone, whether the chatbot redirects them or not. Anyone that messages your Facebook page, you can talk to through here. Or, you can sit back and let your chatbot do the heavy lifting. It's up to you :)
There's obviously much more to know about chatbots, but you have all the tools you really need at this point. Re-Engage and Analyze are both powerful tools worth exploring. For this tutorial, consider yourself qualified to have a professional chatbot.
Thanks for reading!
By Joseph Hansen- Faculty Technology Center Assistant. With questions, email firstname.lastname@example.org
Use for academic purposes. May not be commercially distributed. Current as of December 6th, 2019.