In this instructable we will teach you how to add voice interactive artificial intelligence to your Bluetooth-speaker. This instructable will give an example to make a personal trainer named Kevin. Kevin will give you a workout plan based on your exercise needs.
Step 1: Start Your Project!
The first step to making your own mobile coach is to go to https://console.actions.google.com and click add/import project. A pop-up will appear and you will be able to give your project a name. The second step is to choose your country and click 'Create project'.
Next, you will have the option to choose between creating a:
Dialogflow - this will enable you to use a simple speech interaction builder to create your Assistant app.
actions SDK - this will enable you to set up an SDK and use command-line interface tools to create your actions locally.
Converse.AI - this will enable you to build speech and rich media actions for the Assistant.
For our coach, we will use Dialogflow, since we want to build an interaction between the user and the coach and make it seem real.
Select Dialogflow and click create actions on dialogflow.
This will redirect you to the website
Step 2: Create Dialogue
To create a dialogue, intents should be created. Intents determine which user requests are understood and what action to take. This will allow you to set up an action on which the assistant can respond.
There are two types of dialogs to consider when building voice interaction scenarios:
- Linear dialogs - the aim of which is to collect the information necessary to complete the required action (e.g. find the best hotel, turn on the right light bulb, or play the desired song)
- Non-linear dialogs - which may have several branches, depending on users’ answers
To build linear dialogs, we use a feature known as slot filling.
Since our app understands natural language, our sporters can request an exercise in many ways. Depending on how they word their request, there may be several different search parameters:
-“I want to work out"
-“Man, I feel like sporting"
-“Time to do some exercise!"
Our app requires two parameters to start the optimisation:
- Body region
This is where the slot filling feature comes in. Even before you start listing examples in the User Says section, you can list all of the parameters your app can use to perform a search, both required and optional.
In our example, we start off with introducing. In the images, you can see our filled in possible ways a user can start interacting with Kevin.
In the response section, you can fill in the wished output of Kevin. Here, you can fill everything you want. If you fill in multiple possible responses, Kevins answers will differ each time.
When you mark a parameter as required, you’ll be asked to write prompts that your app will address to your user when they make a request that does not include that parameter.
Your agent will continue to ask these prompts until it has collected information for all required parameters.
In our example, the coach wants to know your name. After the user activates Kevin by saying one of the following:
A prompt is added so Kevin will ask you questions until he got the right answer. After telling him 'Hi' he will greet back and ask for your name. After you gave an answer to this question he will ask what he can do for you.
Step 3: Managing Conversation Flow
The logic behind the conversation has been constructed using multiple intents and setting the right input/output context.
1. First, the main workout intent is created. This intent is triggered by the user saying that they would like to do an exercise. The agent responds to this by asking what kind of region they would like to train and setting the output context to:
2. Second, three sub-workout intents have to be created. The input contexts of these sub-workout contexts have to match the corresponding output-context of the main workout intent. In this example, it will be workout_legs.
The difference in determining which workout should be selected depends on the input of the user. Therefore the intent input of the legs sub-workout can contain the following examples:
2. Lets do legs
3. I want to train my legs
The output context of this sub intent should be configured as the following:
This allows the right intents can be linked. As a response, we can now ask the question: What intensity would you like the exercise?
3. Now, we are creating 3 sub-sub intents that are linked to the different intensity workout plans. First, the input contexts have to match the output contexts of the previous sub intent. The user input should differ according to the intensity of the workout plan. For example, when the user chooses the light workout he or she could say:
I want an easy workout
Based on this user input and considering the input context we just linked, the agent will know that it should activate the easy-leg intent.
Now only a workout plan has to be written in the response section and you are done!
Step 4: Simulating
The next step is to try out your programmed coach.
This can be done by going to -> integrations -> integration settings -> test -> continue
Now you will see the simulator. To test the prototype, you can type, or press the mic button and use speech.
If you filled in the dialogue boxes correctly, you will have a fluent conversation. if not, you can adjust this by going back to the dialogflow.
The nice thing about dialogflow and this application is that you can make it as complex as you want. The more data you put in, the more intelligent your coach becomes. This will improve the way the application work since it will be able to talk and respond more fluently.
Step 5: Possible Integrations
In this tutorial, we show you the basics of what is possible with this DIY artificial intelligence programming software.
This program excels in managing conversation structure, but when you actually want it to perform a task, like fetching weather data about a specific place or provide you with the bus schedules, another means is necessary: Webhooks. With webhooks, it becomes possible to execute basically any given command that comes forth from the dialog flow conversation. Unfortunately, this goes beyond the scope of this tutorial. In the case of this example, it could mean that it would be possible to link exercise preference to a more extended online database of exercises. In addition, it could be possible to link the virtual assistant logic to a hardware device with microphone and speaker.
We hope you find this lesson useful to see how you can easily build your own personal fitness assistant at home. We think diagflow can be a very useful tool in the field of AI prototyping, but without web integration it unfortunatly is limited to only undertanding and managing the conversation.