Skip to main content

My first skill

To get started with skills in Ainhoa, let's create a simple example of a dialog skill to get an idea of the potential this tool offers.

The main idea of the skill we are going to implement is to identify an intent from the user and ask them a simple question, and then act accordingly based on their response.

Using a somewhat geeky πŸ˜‰ example, we'll identify if the user is asking about "Matrix," and if so, we'll propose that they choose between the red pill πŸ”΄ or the blue pill πŸ”΅.

Matrix skillMatrix skill

Create the skill​

The first thing we need to do is create the skill. We will provide the following information in the creation window:

FieldDescriptionValue
TitleName of the skill. Preferably in lowercase and without spaces.matrix_pills
DescriptionBrief description of the skill. Must be provided in each of the supported languages.Use this function when the user wants to know what Matrix is or wants to enter the Matrix.
TypeType of skill. Search or dialogue.Dialog
LanguagesList of languages supported by the skill.English and Spanish
TagsList of tags related to the skill.
Access modeSelect the access mode to the skill. Public access or members only.Public access
MembersList of members who have access to the skill and their associated privileges.
info

You can find more information on how to create a skill at this link: How to create a skill.

Set intents​

Now that we have our skill created, we need to indicate how to identify the user's intent. In this case, the intention is "Matrix," and we will identify it if the user asks what Matrix is or wants to enter the Matrix.

To do this, we'll go to the Bootstrap Intents card in the sidebar and add some phrases that the user might write and that we can associate with our intent. The more different phrases we add, the better our bot will be able to identify the intent. We must provide phrases in all the languages ​​we have enabled.

In our case, we have added the following intents:

Matrix skill bootstrap intentsMatrix skill bootstrap intents

info

You can find more information about the sidebar at the following link: Sidebar.

We're also going to add the possible responses the user might give us as intents. In this case, the options are Red and Blue. Let's go to the Intents tab and add two new intents with values in the different supported languages, as shown below:

Matrix skill intentsMatrix skill intents

info

You can find more information about the Intents tab at the following link: Intents.

Define the steps​

Now that we have created the intents, we can start defining our conversation by adding the necessary steps. In this example, what we want to do is, once we have identified the user's intent to learn more about Matrix, ask them a question to choose which pill they want and then display a message according to their choice.

Therefore, we will need the following steps:

  1. Send a welcome message to the user to let them know that we have detected their interest in learning more about Matrix.
  2. Ask which pill they want to choose.
  3. Provide a response based on their choice.
info

All the information about creating the different steps is available at the following link: Steps.

We will add these steps in the Conversation tab as follows:

1. Welcome message​

We create a step of type Say with our welcome message, we won't provide any condition for it to execute, so it will always be executed, and we select that the next step is Continue. This will allow the flow to move to the next step.

Matrix skill step 1Matrix skill step 1

2. Ask the question​

Next, we ask the user to choose the option they want. We'll do this with a Ask step, not setting any condition so it executes always.

We provide the question text in different languages and select the two intents we added, Red or Blue, as possible response options.

We assign the response to an entity named pill. Finally, we set the next step to Continue to proceed with the flow.

Matrix skill step 2Matrix skill step 2

The user can select one of the two possible responses, Red or Blue, but they can also directly type the response into the chat. If the user's response does not match any of the intents we have defined (#red or #blue), the skill will display a message saying that it did not understand the user's response.

3. Reply message​

Finally, we need to check the user's response and display a different message depending on the chosen option. We can do this by creating two different steps, one for the response if the choice is Red and another for Blue.

We'll use the condition field to identify the selected option and display one message or the other. In this case, since we previously added intents for the possible user responses, we'll create a step with the condition #red, which will display the desired message when the user selects the Red option. And we'll use the condition not #red to respond when the user has selected the Blue option.

We write the text we want to display for each of the options and mark the next step as Finish to end the flow.

Matrix skill step 3 and 4Matrix skill step 3 and 4

info

You're right, we haven't used the pill entity where we stored the user's response. This is because we used intents to provide possible responses to the user. However, we can still use the value provided by the user in our condition, as in the following example: @pill.value = "red".

tip

Don't forget to provide the texts in the different supported languages in your skill to ensure it works correctly for all languages.

Test skill​

We have everything ready to test our skill and see if it behaves as expected. Before proceeding, make sure you have saved the changes by clicking on the Save button.

Click on the Test skill tab where you have a chat to interact directly with our newly created skill. You can change different parameters such as languages for testing purposes.

info

All the information about the Test skill tab is available in the following link: Test skill.

To initiate our skill, simply type in the chat, and you can see how the sequence of steps we defined is executed. You can also click on the chat messages to view associated debugging information, which can be very useful in your testing.

You can make changes to your skill and quickly test the results in different conditions before publishing your new version.

Matrix skill testMatrix skill test

Congratulations! πŸŽ‰ You now have your first skill ready to be used in your bots. You can continue exploring the rest of the examples to keep learning how to harness the full potential of dialog skills in your bots.