Use Google's DialogFlow (formally API.AI) to create an artificial intelligent chatbot for your robot.

+ How To Add This Control To Your Project (Click to Expand)
  1. Make sure you have the latest version of ARC installed.
  2. Select the Get button in this page to download the archive file.
  3. Double click the downloaded archive file to execute installer.
  4. The installer will add this control to ARC.
  5. Load ARC and press the Project -> Add Control button from the menu.
  6. Choose the Artificial Intelligence category tab.
  7. Press the Dialogflow icon to add the control to your project.


Google's DialogFlow (formally API.AI) is a free chatbot service which this plugin will use. Either manually enter conversational phrases into the input field, or send phrases programmatically using the provided ControlCommand(). This plugin requires an internet connection, which means your computer must be connected to both the robot and internet at the same time. Please consult the appropriate lessons in the learn section to configure your EZ-B to WiFi client mode or add a second USB WiFi adapter from here:

*Requires ARC 2019.12.06 or newer

Here is an example of a conversational ChatBot that you can configure with DialogFlow and incorporate other ARC plugins, such as cognitive services for Vision and Emotion detection...

Programmatically send phrases using the following ControlCommand() syntax...


ControlCommand("DialogFlow", Send, "Hello There")

The response from the server is stored in EZ-Script variables. Additionally, a script can be configured to execute when the server responds.

Parameter Functions
Some DialogFlow agents will return a list of parameters. The DialogFlow plugin implements 3 custom functions into the EZ-Script engine for obtaining parameters. The functions are...

Returns the number of parameters in the last response.
Usage: $x = APIGetParamCount()

APIGetParamByIndex( index )
Returns the parameter value at the specified index in the last response.
Usage: $Value = APIGetParamByIndex(2)

APIGetParamByKey( keyName )
Returns the parameter value by the key name. Look at the Agent or Variable Watcher to see what parameter key names are included in the response. The key names are case sensitive.
Usage: $Value = APIGetParamByKey("unit-to")

Here is an example of using the custom EZ-Script functions from the DialogFlow's Unit-Convert agent. If the input string is "What is 5mm into inches?", this EZ-Script code will show what the user is asking...


print("There are " + apigetparamcount() + " parameters in the response")

print("User is asking to convert " + APIGetParamByIndex(0) + APIGetParamByIndex(1) + " into " + APIGetParamByIndex(2))

User-inserted image

1) Register with DialogFlow by visiting:

2) Paste your Client ID in this plugin's configuration window

User-inserted image

*Note: Please consult DialogFlow's website for information on setting up a personal chatbot.

Example ChatBot - Create An Intent For Moving
Once you have some familiarity with creating a new Agent and adding the key to this plugin, we can walk you through how to create an intent. The verbiage used by AI bots is not clear from the beginning. However, once you understand what an Intent and Entity is, it begins to make sense.

The process that we will take in these steps will use text input to teach the bot by typing sentences around a specific action. In this case, we're going to teach the bot how to move a direction (forward or reverse) for a number of seconds. We'll do that by continually typing phrases into the Intent and the bot will create the necessary variables.

Step 1
Load ARC and add two controls to your project. We'll add VARIABLE WATCHER and DialogFlow plugin. Because we'll be having the robot move FORWARD and REVERSE, you'll want to add these controls to an existing project so you can actually see the robot move. If you add it to a blank project, such as this example shows, you'll never have the robot actually move.
User-inserted image

Step 2
Load your Dialog Flow agent in a web browser
User-inserted image

Step 3
We're going to create a new Entity. An entity is essentially a variable that contains a bunch of synonyms. For example, you will see in the next few steps that we will create an identity called DIRECTION which will have two variables FORWARD and REVERSE, but a bunch of synonyms of each. This is how the AI magic understands what inputs people may provide that mean what you expect. So go ahead and create a new Entity.
User-inserted image

Step 4
Name this entity DIRECTION and create synonyms for each direction FORWARD and REVERSE as seen in the image below.
User-inserted image

Step 5
Now we will begin creating an Intent. This is done by pressing the + on the side menu next to INTENT.
User-inserted image

Step 6
Now begin adding phrases into the "User Says" box. This is the magic of AI, because the system will begin detecting the similarities of your statements and create an intent out of them. The sentences you enter must all be related to moving a direction (forward/reverse) for a number of seconds. See in this example the different entries I created. For best results, use the same entries that I did.
User-inserted image

Step 7
The seconds will now be detected as a time parameter, which normally would be a good thing. However, in this case we only want seconds. So we're going to edit the parameter and rename it to SECONDS and set the type to SYS.NUMBER.
User-inserted image

Step 8
Both parameters DIRECTION and SECONDS are required. So we'll need to set the checkbox for required on each parameter.
User-inserted image

Step 9
Now that the parameters are required, this is where the AI magic can have conversations with the user to get more information. For example, if you asked the robot to move Forward and didn't supply a number of seconds, the dialog prompt that we'll enter here will ask the user for how many seconds.
User-inserted image

Here is the prompt for DIRECTION
User-inserted image

Here is the prompt for SECONDS
User-inserted image

Step 10
Once all of the parameters have been provided to the bot during a conversation, the bot will respond. We can create our own response, which is friendly to the user. Here's an example response that uses the variables we created in the previous steps.
User-inserted image

Step 11
When the intent is successful and we wish ARC to do something, we need a way to identify what this intent is. The intent has an Action that is unique. In this case, we'll call the action move.direction.time
User-inserted image

Step 12
Save this Intent and we're done with the Dialog Flow editor and will return to ARC
User-inserted image

Step 13
Back in ARC. let's try out our Intent by typing MOVE and press ENTER in the DialogFlow plugin. Notice in the Variable Watcher that the $APIComplete variable is 0 (false). And, notice the Bot has asked us what direction to move? That is the bot executing the prompt we entered earlier because the parameter for direction is missing.
User-inserted image

Step 14
Respond with FORWARD and you will see the prompt now asking for how many seconds. The $APIComplete is still 0 (false).
User-inserted image

Step 15
Now enter a number of seconds. Notice the $APIComplete is now 1 (true) and the successful response is given.
User-inserted image

Step 16
The system now knows how to determine the direction and number of seconds to move. But, the robot doesn't know what to do with that yet. We will create a script that will execute the movement commands based on these parameters.

Click the CONFIG menu button on the DialogFlow plugin
User-inserted image

Step 17
Edit the SCRIPT
User-inserted image

Step 18
Finally, let's paste in some code that will be executed.
User-inserted image


IF ($APIAction = "move.direction.time" && $APIComplete = true)

IF (APIGetParamByKey("direction") = "forward")

sleep(APIGetParamByKey("seconds") * 1000)



Wow great info here, I was just about to start from scratch figuring out how I would do this and bang there it is at the top of the Forum,almost like you are a psychic ,DJ!:)
Hi, my question is about integrating EZ-Robot JD Humanoid with DialogFlow. In my DialogFlow scenario the agent has a French female voice (FR-Wavenet-A). The question is:  with EZ-Robot JD Humanoid and DialogFlow integrated,  is it possible to retain the same voice for the robot? Thanks.