Скачать бот Либре рабочем столе, ваш личный бот для вашего ПК или Mac
Bot Libre Forum

User's input

по astoimenov опубликовано May 25 2016, 3:56


I'm trying to train my bot via "Training & Chat Logs" and I'm adding new responses there. But I'm encountering some difficulties:

  • when I try to use the user input in bot's response (with "Something {star} something..") as a response I'm getting only the user input, not the whole response
  • I'm asking the user to input a number, but it can be any number, how can I set an response to it?
  • and also can I validate somehow such a number? For example I want one response if the number starts with "07" and another if it's not

Thank you in advance! :)

by admin posted May 25 2016, 13:46
You can use patterns and templates from the "Training & Chat Logs" page.
This lets you do a basic level of programmatic processing.
You can also do more advanced things from the "Scripts" page by writing your own script.

To reuse part of a pattern in a response use the "star" variable. If you have multiple * in the pattern star becomes an array, so use star[0], etc.

You need to prefix patterns with Pattern("") and templates with Template("").
To use a variable or code in a template use {}.


Pattern("Do you like *?")
Template("Yes I like {star} very much.")

Pattern("Do you like * or *?")
Template("I like {star[0]} but I don't like {star[1]}.")

What is the date today?
Template("It is {Date.date()}.")

For inputting a number you probably want to use a script, but may be able to use a response with a default response with a previous as well.

Scripts are more complex, they are written is Self, which uses states and patterns. Self follows the JavaScript syntax.
state EnterCode { pattern "*" that "Please enter your code." template checkCode(); pattern "*" template "Please enter your code."; function checkCode() { if (star.startsWith("07")) { return "Welcome 07 user"; } else if (star.startsWith("06")) { return "Welcome 06 user"; } return "Invalid code"; } }

See also,




Also check out examples in our script library, and it your bot's bootstrap scripts.

Updated: May 26 2016, 9:23
Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 2722, today: 1, week: 6, month: 44

Идентификатор: 12820261
Теги: scripting, self, templates
Опубликовано: May 25 2016, 3:56
Обновлено: May 26 2016, 9:23
Ответы: 1
Вид: 3943, сегодня: 2, неделю: 8, месяц: 60
0 0 0.0/5