Знаете ли вы, бот Либре также обеспечивает бесплатные размещенные чат на свой сайт или мобильное приложение?

How to integrate bot with information sources

по igolubev опубликовано 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,



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.



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: 1815, today: 0, week: 0, month: 11

by igolubev posted Mar 17 2016, 7:36


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: 1556, today: 0, week: 0, month: 12

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.


Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1742, today: 0, week: 0, month: 14

by igolubev posted Mar 18 2016, 7:16


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: 1671, today: 0, week: 1, month: 15

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,


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.


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: 1726, today: 0, week: 0, month: 11

by igolubev posted Mar 26 2016, 3:42


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: 1540, today: 1, week: 1, month: 11

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: 1682, today: 0, week: 0, month: 12

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: 1592, today: 0, week: 0, month: 9

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: 1561, today: 0, week: 0, month: 8

Идентификатор: 12378939
Теги: integration
Опубликовано: Mar 15 2016, 7:50
Ответы: 9
Вид: 2650, сегодня: 2, неделю: 4, месяц: 49
1 0 4.0/5