First, let’s highlight all the benefits of adding conversational capabilities to your support pages and bots:
- Your real support agents won’t have to deal with as many repetitive questions — the most frequent requests will be handled by their artificial sidekick.
- The automated agent will cover the real ones at inconvenient shifts like nights, lunches, vacations, public holidays, rush hours, or just lazy hours.
- Having more free time available for more important and creative tasks, your human support agents can spend that time working with more complicated tasks or creating interaction scenarios for the artificial support agent. Or maybe work on something else.
- Having instant answers to their questions, your customers will be much happier.
The agent we’re going to talk about in this article is designed to automatically reply to the most common questions to an imaginary online store customer support about shipping, return policy, and order status. Of course, this is a demo agent and the most frequent questions for your company will be different. Its goal is to give you an idea on how to create a smart automatic support agent using API.AI tools.
Start by creating an agent. Ours is called OnlineStoreSupport.
If you choose to use our demo agent, here are the instructions on how to import it into your account.
Before you do anything, outline a few main questions you want to start with. This will help you to structure the agent.
An intent in your agent represents a mapping between what a user says and what action should be taken by your product. Every intent you create should correspond to one question. In the intents you will write all the different ways of how those questions may be phrased by your customers. Don’t worry, you won’t have to write all of them. We’re using machine learning to train your agent to understand a lot more variations based on the examples you provide in intents.
Now we’re ready to create our first intent. From anywhere in the console, click the plus button next to 'Intents' in the left side menu. If you’re in the Intents tab already, click the 'Create Intent' button.
We will call our first intent "shipping.locations". It will capture questions about locations that our online store delivers to. We already have a few examples of questions in there. Note that while you’re writing examples in the 'User Says' section, the system will try to annotate them automatically to extract the relevant information from your customer requests. If you don’t like the way your examples are annotated, you can change them any time you want. You can change the entities used, parameter names, and the part of the annotated phrase. Or perhaps you want to remove the annotation altogether.
Give the action a name, so the request has something to map to. In our example, the action name will be the same as the intent name – "shipping.locations". You can choose any name you like.
If there is no special logic that needs to be applied to provide a response, you can write it right here in the intent. That’s what we did.
Looks like we’ve covered everything. Click 'Save' and our first intent is ready. It takes a couple of seconds to train the machine learning model for your agent with the new information.
Now let’s test our first intent. Even on the small training set like the one we have here, our agent recognizes a lot of other variations pretty well.
While testing your agent in the test console, you can see how your requests are recognized and what responses are given. You can see the JSON with details right there too.
You can do it by clicking the plus button next to 'Entities' in the left side menu. If you’re in the list of entities, click the 'Create Entity' button.
In our agent we used 2 types of entities.
Developer mapping entities are basic entities, where you list entries and synonyms for them. In our agent, they are
Composite entities can contain other entities. When you create a composite entity untick the ‘Define synonyms’ option and list entities (or combinations of entities) with the name of their alias after
@sys.geo-city:city). See the
Create Fallback Intent
Now we have intents that help our store understand what the guests are asking. We also need a way to understand requests that the agent is not trained for yet. For this purpose, we added a fallback intent. It’s a special intent that matches all the requests that don’t match by other intents.
The same way as regular intents it can return an action of your choice, so you could form a response. You can also write responses in the 'Text response' field.
There are a few ways of how you can deliver responses to your customers:
- Write responses directly in the intents, just like we did in our demo agent. This is the simplest way, which is convenient if no conditional logic is required to form the responses. Basically, it’s good for Q&A types of agents.
- Use a webhook to connect to your business logic. See an example here. 3.Use one of the SDKs to send requests and get responses from our API.
Context is a very powerful feature which you can use to build a conversation scenario with multiple follow-up questions, pass parameter values from one request to another, or use information from your app, device, or your user profile to help your business logic form the best response.
We used contexts to understand follow-up requests. Let’s look at the "return.policy" intent. It understands various ways how people request information on our return policy. We expect some follow-up requests when our customers specify why they may want to return an item.
To understand that the follow-up requests are related to the initial question, we created an output context "return-policy" in the initial intent.
Then we create another intent “return-policy - reason”, which will catch only follow-up requests like “What if I broke it?”, “Actually it was damaged.”, and so on. To make it work only after the initial requests, we use the "return-policy" context as an input context. This way the examples and their variations that we use in this intent only work when the "return-policy" context is active.
Read more about contexts in the docs.
Integrate with your app, website, or bot
Our agent has learned to understand people and answer in a proper manner, so the real support agents could pick up the conversations that were beyond our agent’s capabilities. Now, it’s time to integrate it into your app, bot, or website. Your agent can be easily integrated in all major platforms. Have a look at the complete list integrations and SDK’s here.