Home
Mailgun Blog
IT & Engineering category
Chatbot Development Tips: Get Started with Conversational AI
IT & Engineering
Chatbot development tips: How to get started with conversational AI
Chatbots are having a moment right now. Get some essential information on what goes into building a bot and discover best practices for developers to follow as you enter the world of conversational AI.
PUBLISHED ON
The rise of the chatbot is here. And if you want to stay on the good side of these artificially intelligent creations, you should probably know a thing or two about building them. To paraphrase Sun Tzu’s well-known saying: “Keep your friends close and the bots closer.”
All kidding aside, chatbots are becoming a pretty big deal. And while we’re all about email at Sinch Mailgun, there are some big advantages to using chatbots to enhance the user experience. Namely, chatbots can provide immediate responses... any day, any time. Chatbots can also increase product adoption, help users navigate your app, and answer recurring support questions.
Understanding how chatbots work and how to build a bot will help you diversify your skills and make you an even more valuable developer.
Of course, the stereotypical image of a software developer is someone sitting in a dark room surrounded by screens filled with code as they gulp down copious amounts of caffeine.
Maybe there’s some truth in that. But the best developers also understand how to build an ideal user experience. When it comes to chatbot development, that includes a knowledge of the ways people speak, text, think, and feel.
As we learned from Fréderic Godin, Head of AI at Chatlayer by Sinch, there’s a lot more to building a chatbot than code.
Table of contents
Chatbots and NLP
Chatbots and data
When a chatbot gets stumped
Make a proper introduction
Start simple
Make it dynamic and efficient
Let your chatbot learn
Consider your return on development
The basics: How do chatbots work?
A chatbot is a piece of software that’s programmed to simulate a human conversation. According to CX Today, there are three primary methods for running a chatbot:
Pattern-matching is a method that rule-based bots use to classify text and respond based on keywords they recognize in the questions.
Other bots use algorithms, such as the Multinominal Naïve Bayes algorithm, which is designed to analyze text inputs and solve problems with numerous classes.
Even more advanced chatbots use artificial neural networks, which are more complex algorithms that are based on the way neurons work in the human brain.
The most effective chatbots use natural language processing (NLP), which is a branch of artificial intelligence (AI). The goal of NLP is to help machines understand the way people communicate so the AI can generate a useful response. As Fréderic explains, a good chatbot can even identify human emotions.
“Through natural language processing, the bot can understand if a person is feeling angry, happy, or neutral. And it can respond accordingly.”
Fréderic Godin, Head of AI, Chatlayer by Sinch
Some bots respond to text communications while voicebots let people interact over a device through speech, eliminating the need to type.
While all chatbots use basic business logic to deliver pre-defined responses to questions, rule-based or pattern-matching bots can only do so based on a limited number of questions and recognizable keywords. However, chatbot technology has progressed way beyond that.
More advanced bots use machine learning to expand their knowledge and capabilities based on user requests and interactions. Over time, these bots are programmed to get better at responding to real people based on the conversations they’ve had with users.
This is what’s known as conversational AI. That’s when a bot uses NLP, machine learning, and conversational design to replicate a realistic person-to-person interaction. To put it simply, conversational AI makes chatbots sound human, not like a robot.
That’s an extremely complicated challenge. Consider the fact that it takes the typical person until the age of 12 to learn the 20,000 most common words in their native language. So, imagine developing an effective, multi-lingual chatbot for an international organization.
Thankfully, a lot of the groundwork has already been laid down. Chatbot building platforms like Chatlayer by Sinch help simplify and streamline the process. A bot can be built in one language and understand more than 100 others without being retrained.
How chatbots answer questions
People can ask the same question in a lot of different ways. That’s why Fréderic says a well-programmed chatbot needs to be able to handle a variety of queries. It can use machine learning to do that, but you’ve got to give the bot something to work with first.
“When you want to build a bot, you will give it some examples of how people ask something. For example, if you want to let people order pizza, you will give the bot five ways that people typically order pizza. Based on those examples, we actually try to make sure the bot understands all variants of the ways people order pizza.”
Fréderic Godin, Head of AI, Chatlayer by Sinch
Fréderic says a best-in-class chatbot should also understand misspellings, typos, slang, synonyms, and phrases that have words arranged in different orders.
Chatbots and NLP
When chatbots use a natural language processing engine, they can interpret a wide variety input from users, even without the most important keywords in the user’s message. Plus, an NLP engine helps bots process typos and other errors.
Of course, it’s a lot more complex than the image above. Here are several key terms related to NLP and the chatbot experience:
Messages and expressions
Intent
Confidence rate
Responses
Entities
Sentiments
Together, these terms make up the basic components that, when connected, create the flow of a chatbot conversation. Learning how to build these flows is a practice known as conversation design.
A message is the question or comment a customer or user sends to the chatbot: “I want to order a pizza.” This message gets mapped to an intent before being sent to the chatbot.
An intent is the overall goal the customer wants to achieve. In this case: Place order for pizza.
Of course, there’s more than one way to ask for pizza. Expressions represent the different ways to make the request:
“Can I order a pizza?”
“I need a pizza ASAP.”
“I’m hungry for pizza!”
When a customer sends a message, the NLP engine tries to understand the expression and map it to the right intent. It also gives the message a confidence score, which rates how sure the technology is about the intent prediction. Developers can set a confidence score threshold, so that if it’s too low, the bot can deliver a “not understood” response and possibly ask the customer to rephrase for clarification.
Responses are (go figure) what the bot sends back to the customer. That’s not always a direct answer. Many times, it’s another question that helps clarify the message and keeps the conversation going. Plus, including various bot responses makes the interaction feel more authentic for returning customers.
“Sure, what kind of pizza do you want?”
“Definitely, what size would you like to order?”
“Of course! Will this be delivery or pickup?”
Entities are phrases found inside an expression that provide information a chatbot will eventually need and suggest the type of response it should deliver. For example, a customer’s initial message about pizza may include size or toppings. So, the chatbot should process that information and provide an appropriate response without having to ask the question later.
Customer: “Can I order a large pizza?”
Bot: “Sure, what do you want on your large pizza?”
Finally, sentiments in a message provide clues to the chatbot about how the person is feeling. For example, if the individual sounded frustrated, the bot could respond with an empathetic apology.
Customer: “Where the heck is my pizza?!”
Bot: “Sorry that you’re still waiting. Let me see if I can help.”
The NLP engine maps the message to the right intent, but it also pulls entities from the expression and may pick up on sentiment in order to send an appropriately tailored response.
Here’s a table showing how this entire flow might work in the travel industry:
Click to see a full-sized graphic
Chatbots and data
Another important factor in chatbot development is having a foundation of reliable data. You need user data to uncover details about the kinds of questions the bot will be answering. Then, you need a database that helps the bot provide the right information in response.
Let’s use Alexa as an example...
If you ask Alexa, “What’s the weather today?”, the AI already knows where you’re located. That’s a piece of data it has about you. Then, it needs to connect to a database with up-to-date weather information for your location so it can tell you the forecast.
An effective conversational AI solution will integrate with other platforms in order to access data that improves and personalizes the chatbot experience. For example, Chatlayer integrations include tools like Salesforce, ZenDesk, and Hootsuite.
Fréderic says one way to take advantage of zero-party data in conversational AI is through access to customer support logs.
“If audio was recorded between callers and live agents, we have tools to identify the most frequent questions asked and how people typically ask them. That way you get some insights and data, which you can use to build a bot based on what customers actually ask in your call center.”
Fréderic Godin, Head of AI, Chatlayer by Sinch
When a chatbot gets stumped
Chatbots also need to know what to do when they either can’t satisfy a customer or don’t have an answer to the problem. In this case, Fréderic says NLP, including the ability to identify emotions, comes in very handy. Developers can program bots to recognize when a customer needs a live agent.
“You can say, ‘Well, if they’re really angry, maybe we should send this person to the call center rather than letting them keep talking to the chatbot.’ But if the customer is neutral, the bot could ask them to rephrase a question it didn’t understand.”
Fréderic Godin, Head of AI, Chatlayer by Sinch
An interesting observation that Fréderic makes about chatbot interactions is how people will change the way they ask questions after they realize they’re talking to a bot. When necessary, people seem to “dumb things down” a bit for the bot. It seems that we are adapting to bots as they learn to understand us.
Digging in before you begin
While knowing how to code will certainly be a big benefit in chatbot development, you also need to take time to plan the project. Here are five key questions to ask before you start building a bot:
What’s the goal? Is there something your organization hopes to accomplish by developing a chatbot? Why do you need one? Determine what an effective chatbot experience will look like and measure the results.
What are the use cases? How will the chatbot be applied in the real world? Will it play the role of a customer support agent, or will it recommend products? Do you want it to help people place and track orders? Should it be able to book appointments? Be sure to clearly define what the bot will do.
Who will interact with the bot? Understanding the users and their needs is extremely important. Think about what your audience would expect from a chatbot experience and get advice from colleagues who have direct contact with customers.
What’s your chatbot’s personality? You want your bot to sound authentically human, but that could change depending on the industry and the customer. Should it be formal and polite, or would your users like to engage with a playful chatbot? Your marketing team might also want the bot to reflect a specific brand voice. If it’s a voicebot, you’ll literally have to choose a voice with a sound that fits your bot’s desired personality.
Where will your chatbot live? Conversational AI can take place on a website, via SMS, social messaging apps, through call center automation, or inside your software. The channel you choose can impact chatbot development choices.
Best practices for chatbot development
When it’s time to start building your bot, Fréderic Godin and the team at Chatlayer by Sinch have plenty of advice. Here are some of their best chatbot development tips:
Make a proper introduction
First impressions are important. The way your bot introduces itself to your users sets the tone for the conversation. Plus, it lets people know exactly what to expect from the chatbot.
Here’s an example:
“Hi, James! I’m Bessie, a virtual assistant here to help you figure out how to build a website for your small business.”
What can I help you with today?”
In this example, let’s say because the user is logged in, the bot is also able to personalize the introduction with the individual’s first name.
Start simple
When you get started with chatbot development, all those potential questions and various expressions can be overwhelming. Fréderic says the best thing to do is choose an easy customer problem and build from there.
“We recommend picking one use case that you want to tackle first. Typically, it’s one that is very repetitive and not too difficult to answer.”
Fréderic Godin, Head of AI, Chatlayer by Sinch
For example, Fréderic suggests answering a question with a polite response in which the bot simply provides a link that points users to a web page where they can find the answer they need.
Make it dynamic and efficient
As your chatbot development project gets more advanced and complex, look for ways to reduce the amount of work you and your bot have to do. That could mean reusing bot dialogs and variables when possible.
You should also make sure your chatbot is able to access and reuse information. If you ask for a customer's order number once, the bot shouldn’t need to ask again later in the interaction.
A dynamic chatbot is resilient to change. You can program a dynamic chatbot by having it access information from external databases rather than hardcoding it into the bot. Your external database serves as the “source of truth.” So, when you update the database, your chatbot will be updated too. You only need to make the change in one place.
Let your chatbot learn
Don’t expect perfection when your chatbot finally starts interacting with humans. Chatbot developers can learn a lot from observing what works and what doesn’t.
“Put your bot in the wild as quickly as possible. See how customers use the bot. Based on that, add new expressions to the bot that resemble real questions. Like, how do people really ask to order pizza?”
Fréderic Godin, Head of AI, Chatlayer by Sinch
You’ll find more bot-building best practices and a conversation design checklist in Sinch’s Chatlayer documentation. There are also pre-defined chatbot building templates for select industries, which can help you get a jumpstart on building and customizing your bot.
Consider your return on development
Even though Fréderic is a big proponent of chatbots, he readily admits that at some point things get too complex, and you need a human to intervene. The more advanced messages from users become, the more time and resources go into developing the AI. So, you end up facing diminishing returns on your work.
“Can you get to the point of being fully automated? Probably. But the closer you get to 100% automation, the more investment you will need to make that happen. So, there will always be a fraction of questions, I think, that you will need a human for.”
Fréderic Godin, Head of AI, Chatlayer by Sinch
For that reason, make sure you program a chatbot to send customers to live agents for help when the AI is likely to fall short.
More about improving experiences with chatbots
Chatbots have become a useful technology for omnichannel communication. That’s an approach to user experiences that allows for consistent interactions between people and brands on whatever channel the user prefers (SMS, voice, email, messaging apps, etc.).
Fréderic points out that you can customize a chatbot experience based on the channel where a conversation is taking place. For example, you may want chatbot responses on Instagram to sound more informal than those presented in a chat function built into your application.
Of course, the best way to build a better user experience is to understand what’s going on inside a customer’s head. You don’t need to be a mind reader, but it is useful to understand the customer’s story.
To help you do that, our friends at Sinch Mailjet put together a free ebook on what they call “the omnichannel hero’s journey.” In the ebook, you’ll discover what your users have in common with familiar heroes like Luke Skywalker and Harry Potter. Plus, you’ll get some ideas for what sort of role your chatbot could play in the story. (Hint: R2D2 and C3PO are two pretty good guesses.)