Asked — Edited

Api.Ai Example To Learn A Little Bit From

I have been working in API.AI for a while and jumped back into it yesterday some. I want to describe what API.AI is and what it isn't so that there is a clearer picture of it. I am attaching a sample api.ai project that you can use to start building from if you would like to do so.

First, what is it? API.AI is great at taking speech and breaking it down to give you the intent behind the speech. For example, in the example, you can say something like "Hey Robot, I want you to raise your right arm 19 degrees". The returned text (what would be returned to ARC) is "[Movement] [RightArm] [up] [19] [deg]". You can use a script to break down what the robot is being asked to do from the information above. The phrase "yo, raise your right arm 1 degree" would also work and return "[Movement] [RightArm] [up] [1] [deg]" for you to parse and use.

There are some chatbot features called "SmallTalk". This works like any other chatbot and takes questions or statements from the user and returns text that you want it to return. This is the simplest form of using API.AI and probably is the easiest part of it, but is also not the most useful.

There are some prebuilt agents. These agents each use their own API key. Because of this, I don't recommend using them because the plugin only allows one API key, and you will quickly run out of allowable uses. It is far better to build a single customized agent which contains everything that you want your robot to use.

The use of this tool is to break apart and parameterize language. This allows you to use completely different speech for specific commands in ARC. Currently, the plugin only sets 2 variables in ARC. This requires that you pass the parameters in API.AI back in the Text response field that would match the layout of what you want to parse.

In addition, you can add what are called integrations. This is where you could tie into many different things like Actions on Google, Microsoft Cortana, Amazon Alexa skills, telegram, skype, twitter, facebook messenger and many other one-click integrations. There are also SDK's for Android, IOS, Ruby, HTML5, JavaScript, Node.JS, Cordova, Unity, C#, C++, Xamarin, Python, PHP, Java, Botkit and Epson Moverio that allow you to write whatever you want with whatever language you want for the most part. These integrations allow you to run code instead of simply returning the meaning of what was stated back to ARC.

The example here doesn't use integrations, but is designed more to have the information sent back to ARC for you to do something with.

This is a very scaled down version of the Rafiki client that I had been working on. Rafiki-Client.zip You can take this and import or restore it into your api.ai project.

I hope this example helps people see what API.AI can be used for and better understand where it fits in your robot brain.


ARC Pro

Upgrade to ARC Pro

Stay on the cutting edge of robotics with ARC Pro, guaranteeing that your robot is always ahead of the game.

#10  

@David, glad to see you getting Back to the api, I just finish my robot and will be trying this example along with DJ's plugin soon.

Thanks for your work David.

#11  

@David or anyone who knows.
I'm trying to understand who this works, on David's API-AI example it has this in the script .


if(length($APIAction) > 0)
  if($APIAction = "cancel")
    say("Cancelling Action")
  endif
  if(SubString($APIAction,0,5) = "small")

I think I understand the >0 means if no text or nothing heard, right? just not sure what the 0,5 means.

Thanks,

#12  

@David, I know you have your hands full these days, but have you tried your example with the move forward using your API.ai example plug-in you created ? When I try it, I get "input.unknown" under the $Apiaction in the variable watch. Also it does not speak the return response to my speaker when I say "robot moveforward" but if I just asked a generic question then it speaks the response.

Any help would be most appreciated when you have time of course. Thank you, mike

#13  

@merne The ">" is the greater than comparison... what that line of code means is if $APIAction is not empty. Meaning variable contains data

 if(length($APIAction) > 0)

Substring command is looking for a specific set of characters in a longer string of characters like a sentance... In this case the word "small" starting at character 0 and reading for 5 characters (the length of the word "small")...

(SubString($APIAction,0,5) = "small")

All these commands are listed in ez script including examples on how to use them...

#14  

To use this example, you have to import the zip file into API.AI which tells API.AI what the Move Forward action is. Did you do this step?

In api.ai terms the zip file contains the actions that I used in the example.

#15  

I guess I'm confused here, when you say import the zip file, do you mean unzip it in the API.AI folder where the plug-in resides this is where I'm confused.

I re read your tread and still confused. Maybe I just don't get the stuff because I see Dave s. has it installed and working. So I must be missing something.

I have the zip file not sure where to unzip it to.

Thanks David,

#16  

in API.AI website (where you got your API key from) you would import the zip file into your api.ai project. This will give you the actions you need for this example to work.