• Home
  • blog
  • Customizing Your Assistant with Intent and Context

Customizing Your Assistant with Intent and Context is a really simple service that allows developers to create their own basic personal AI assistant that works a bit like Siri and Amazon’s Alexa. Last week, I covered how to build your own AI assistant using where I showed the basics of setting up an AI assistant and accessing the pre-existing knowledge base that the service provides. In this article, I’d like to go a step further and introduce “intents” and “contexts”, a way of teaching our AI assistants more specific actions that are personalized to our own needs. This is where things can get really exciting.

What is an Intent?

An intent is a concept that your assistant can be taught to understand and react to with a specific action. An intent contains a range of contexts that we can enter as sentences that the user might say to our assistant. A few examples could include “Order me lunch”, “Show me today’s daily Garfield comic strip”, “Send a random gif to the SitePoint team on Slack”, “Cheer me up” and so on. Each of those would be custom intents which we could train our assistant to understand.

Creating an Intent

To create an intent, log into the agent you would like to add the new functionality to in the Console Page and click on either the “Create the first one” link, the “Create Intent” button next to the “Intents” heading at the top of the page or the “Intents” plus icon in the left hand side menu (you’ll need to click the hamburger icon to open that):

Creating a new intent in

For the sample intent for this demo’s assistant, we’d like to teach him to cheer people up when they’re feeling down with movie quotes, jokes and other things. To start, we will call the new intent “Cheer me up” and write our first trigger sentence underneath “User says”. The first sentence I’ve added below is “Cheer me up”. Hit the Enter key or click “Add” to add your sentence:

Setting up our first intent

Typically, we have a range of different ways we might say the same thing. To account for these, we will add in a range of statements which represent various ways a user might indicate they’d like cheering up such as “Make me smile” and “I feel sad”:

Cheer up sentences

Now we have a range of sentences which the assistant should understand, but we have not told it what action is expected when it hears them. To do so, we create an “action”. The assistant will return “action” names back to our web app to allow it to respond. In our case, we won’t respond to the first action which has been called “cheermeup”. We won’t actually use this action name in this demo, but it will come in handy in future when responding to actions in our web app. I’d recommend always including action names for your intents.

Creating an action

We can add in parameters into our actions too, however I will cover that in detail within my next article on!

Guiding Via Speech Response

After our user has told the agent that they’d like to be cheered up, we want to guide the conversation into the user telling the agent more about what they’d like. To do so, we provide speech responses in the form of questions within the “Speech Response” section. For example, “Let’s cheer you up! Would you like a joke or a movie quote?”

Our speech responses

Finally, we click the “Save” button next to our intent name to save our progress.

Click to save your agent

Testing Your Agent

We can test out our new intent by typing a test statement into the test console on the right. Let’s test it out by saying “Cheer me up”:

Our first test

The agent responds back with one of our trained responses as intended. We can also have variations on the phrasing of the statement, often will still work it out. For example, “Make me smile please”, “Say something to make me smile” or “I feel sad right now” will result in our intent running too:

A second test variation

One thing you might notice if you used a statement like “I’m sorry to hear that! How can I help you feel better?” is that it isn’t quite specific enough to guide the user. If they aren’t aware of the options of either “movie quote” or “joke”, then they might ask for something we don’t have covered! Over time, we can train up our agent to understand many other concepts, however for now I’d recommend being specific with your questions!

Continue reading %Customizing Your Assistant with Intent and Context%