Did you know Bot Libre also provides 3D avatars and a free web speech API?
Help

How to integrate bot with information sources

by igolubev posted Mar 15 2016, 7:50

For example: bot is deployed on Facebook or other site. How can I teach the robot to respond to the user by the name (if I can get this name from FB's API)?


by admin posted Mar 16 2016, 7:22
In our Facebook integration, for post and message replies the users name is automatically set. So you can access the user's name the same way as in chat.

For example see the following posts reply by Brain Bot and Julie Bot,

https://www.facebook.com/brainchatbot/posts/1688537148069368

https://www.facebook.com/juliechatbot/posts/161956120856952

These use the MyNameIs Self script that is a default bootstrap script.
To access the user's name is Self you use the speaker variable and its name.

For example in a template reply,

Template("Your name is {speaker.name}")

You can also use the AIML name variable.

For other services, we support classes in Self for,
  • Facebook
  • Twitter
  • Freebase
  • WikiData
  • Wiktionary
These classes have API that lets you do thing like tweet, post, lookup words, etc.
You can look at the WhatIs or WhereIs scripts in Self to see how to access these classes.

https://www.botlibre.com/script?id=482056

https://www.botlibre.com/script?id=482112

You can also access these services using the request() function in Self on the sraix tag in AIML.
Request/sraix also let use access Pannous, and the AIML 2 sraix web API that you can implement your own webservice to access any other service.

For advanced integration, you can implement your own Sense class in our open source code base of Bot Libre.

Updated: Mar 16 2016, 7:24
Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1938, today: 0, week: 0, month: 20

by igolubev posted Mar 17 2016, 7:36

Thanx!

Is it possible, for example, to import knowledges into conversation using web API + self script ?

1. The chat window appears on the html-page by JavaScript SDK, user begins a conversation.

2. I get some data from other services using JavaScript on the same html-page.

3. I call the web API from JavaScript for the current conversation.

4. Self-script processes the call and saves the data for the conversation.

How can I get the conversation Id (to prepare web API-call) in this case?


Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1677, today: 0, week: 3, month: 21

by admin posted Mar 17 2016, 14:37
That should be possible.
The SDK chat() call will return the conversation id in its ChatResponse. You could then send another chat message with this id that invokes a Self or AIML script that sets data on the conversation.

Here is an example script.

http://www.botlibre.com/script?id=12386673

Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1867, today: 0, week: 2, month: 21

by igolubev posted Mar 18 2016, 7:16

Great!

I'd like to use JavaScript SDK. It creates new conversation by sending the first message, but I don't know how to use JavaScript SDK with session Id as a parameter (if I've already started a conversation via web API). Or what is the easiest way to get the current conversation Id from JavaScript SDK (to use in for web API)?


Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1776, today: 0, week: 1, month: 18

by admin posted Mar 20 2016, 12:21
For the JavaScript SDK you use the SDKConnection chat() API to chat with a bot.

The API takes a ChatConfig object which has a conversation field you can set to chat in the same conversation,

http://www.botlibre.com/jsdoc/symbols/ChatConfig.html

The chat() API returns a ChatResponse object which has the same conversation field that gives the current conversation ID. Use this ID in your next chat() request.

http://www.botlibre.com/jsdoc/symbols/ChatResponse.html

In the web XML API, the conversation is an attribute in the chat message and response XML. In the web form API, the conversation is a form parameter.

Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1862, today: 0, week: 5, month: 33

by igolubev posted Mar 26 2016, 3:42

http://www.botlibre.com/script?id=12386673

I'm trying to import this script in my bot (I've saved it in a file), but the error message appears on the import page. The same problem if I try to copy some other self-script (whatis, whereis).

What is wrong?


Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1647, today: 0, week: 3, month: 19

by igolubev posted Mar 26 2016, 4:41

Script works if I paste it in a created script (without import). It's ok.

How can I save more than 1 value for the conversation? This code does not work:

conversation[speakerFirstName] = star[0];
conversation[speakerLastName] = star[1];

After it's execution both variables return value of star[1].


Updated: Mar 26 2016, 4:43
Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1798, today: 0, week: 4, month: 23

by igolubev posted Mar 26 2016, 4:52

Sorry for a stupid question. It works so: 

conversation.speakerFirstName = star[0];
conversation.speakerLastName = star[1];


Updated: Mar 26 2016, 4:53
Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1691, today: 0, week: 3, month: 20

by admin posted Mar 26 2016, 9:20
Glad that you got it working.

What error did you get when trying to import the file?
Ensure that you are importing it as Self, not AIML.

Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1661, today: 0, week: 5, month: 23

Id: 12378939
Tags: integration
Posted: Mar 15 2016, 7:50
Replies: 9
Views: 3021, today: 1, week: 10, month: 73
1 0 4.0/5