Api.ai Chatbot Integration

 
#1

Hey guys, I have been researching a bit on the api.ai and found a simple way to use it on my laptop or phone by using this code from GitHub...

https://github.com/sitepoint-editors/Api-AI-Personal-Assistant-Demo

Just change the accessToken and you are good to go... Grin

Maybe someone from the forum with more scripting abilities could use this to create a plugin for EZ-Builder? Winky

#2

Hey guys, this morning I realized it will take some time until I will be putting up a YouTube clip, since I am just too slow in getting this type of stuff done...I am also still kind of in the middle even getting my robot ready for the testing environment! Grin

So I thought to pace things up a little I will just upload a working version of the script to my serverspace for you to test it out... it is just a simple bot with the native smalltalk agent, no training whatsoever! Winky

The only thing I did to bridge it with EZ-Builder is to add a httpGet(theUrl) fuction after the respond(spokenResponse) funtion which sends the variable that is returned by the query within the action parameter, in this case it would be smalltalk.greetings or smalltalk.greetings.hello etc , over to the server to trigger a command for the robot! Smile

What I am still trying to accomplish would be getting data into api.ai...eg to store data lets say via IFTT MakerWebhooks to the server in a correct format so the fullfiment in api.ai will be able to read the data correctly.
Any information on this would be highly appreciared!

I uploaded the code for testing, and could also leave it there if we would decide to collaborate in building and agent, or just as a testing enviroment! Smile

http://www.downtown-tattoo.de/robotics/test123.html

*edit* same problem on the link...please remove https and put http to your browsers address bar...

#3
#4

@DJSures Man you are the best!

I will check the plugin right now, this is awesome! Grin Grin Grin

#5

The plugin works great! I would love to do some copy and paste hacking on it if you would mind to share the Visual Studio Project... Smile

I tried to follow the instructions on how to create a plugin but had trouble with the .net version and with compiling the project, but I guess if I had a working file I could try to get into how it has been set to work!

What I would like to get done are basically two things, one would be to send some data to api.ai from within EZ-Builder...the other thing is that it would be great to also have the other returned variables exposed in EZ-Builder rather than just the speech variable! (this should not be too much of a problem I guess?)

If for instance the actions variable would be exposed, we could use it to drive our robots actions which are be tied to the variables value...eg if actions would return smalltalk.greetings, this could be used to trigger a certain movement!

Thank you so much for this great plugin! It is awesome to have this integrated within EZ-Builder! I know that you are super busy so it is very much appreciated! Grin Grin Grin

#6

1) use the ControlCommand() to send data within EZ-Builder

2) I can add the other variables

#7
#8

@DjSures Grin Grin Grin You are awesome! Grin Grin Grin

This is supercool, it all works as a charm!

The only thing is that I am still a little puzzled on how to send data over to api.ai, it appears to be a little difficult...if webhooks are enabled api.ai seems to be needing a response which includes a header and a body...something like this!

Code:


Headers:
Content-type: application/json

Body:
{
"speech": "Barack Hussein Obama II is the 44th and current President of the United States.",
"displayText": "Barack Hussein Obama II is the 44th and current President of the United States, and the first African American to hold the office. Born in Honolulu, Hawaii, Obama is a graduate of Columbia University and Harvard Law School, where ",
"data": {...},
"contextOut": [...],
"source": "DuckDuckGo"
}



So how would I send my variable to api.ai using the ControlCommand() function?
a more detailed description on webhooks is documented here...

https://docs.api.ai/docs/webhook

#9

Read the example in the description of the plugin. Forget about webhooks. Forget about json. Forget about wget. Read the plugin page. I took time to write how to use it AND provided an example.

Just use the plugin and send the text using ControlCommand()

#10

@DjSures I am really grateful and I am sorry if I am too bad to understand how this works! It might also be something that is not as easy as I thought it is!
My idea was to store data to a variable within EZ-Builder...eg my sleep being logged from my Fitbit, and this data would be accessible to api.ai!
Maybe this approach is super wrong...I will think about it before I keep on making random requests here! Winky


The plugin works great, speech can be send via the Bing Speech Recognition and is returned properly, the ControlCommand() is working super easy to send speech over to api.ai!
The action paramenter is returned and can be used to drive the robot! Grin


Thanks so much for getting this done, I guess the best approach is to do the logic within EZ-Builder rather than sending the variable out to api.ai?


*edit*

I was just reading this post again, and just wanted to state that by no means I meant to say the plugin is useless for what I want to achieve! It works great, I just need to make a recap of my approach and find the right way to get things done!

Thanks again for putting in the effort to write a plugin! This is great!