How a Chat Bot in Yioop behaves is determined by how it is configured in its Bot Story activity. A Bot Story is a set of patterns that control how a chat bot reacts to group threads posts for groups to which it belongs. A bot story pattern consists of the following components which are configurable in the Bot Story activity:
Request Expression
This and the trigger state are used to determine if a bot will react to a post. If a post contains @name_of_the_bot followed by some phrase or phrases which match the expression and the trigger state matches the trigger state of the bot for that user, then the pattern will apply. Request expressions are allowed to contain variables. They are strings beginning with $ followed by a sequence of word characters. For example, the expression:
What is the weather in $location?
would match the string
What is the weather in San Jose?
and the value of $location would get bound to San Jose in this match.
Trigger State
A chat bot has a particular state it is in with respect to each user in a group. This state can be any string, but it starts at being the string "0". If the current state of the bot for a user matches a pattern's trigger state and the last post of a user matches the request expression for the pattern then the pattern is activated. In the add pattern/edit pattern forms one can use simple strings or strings containing variables in defining a trigger state. For example, "0", "asleep" are simple trigger states. One can also have "1$location". If the request expression for a pattern was "What is the weather in $location?" and the user was in state "1San Jose" and posted a message "What is the weather in San Jose?" then this pattern would activate.
Remote Message
If a bot url has been configured for a chat bot, then when a pattern is activated a request will be made to that url as part of computing the response the chat bot makes to the message which was just posted. The url request will have as part of its query string a variable remote_message which comes from this field of the Bot Pattern. The Remote Message can be any string and is allowed to have variables in it. So for example, a pattern's Remote Message might be getWeather,$location. When the value of $location is substituted with might become getWeather,San Jose. This tells the bot url site what action to perform with what value.
Result State
This is the state the chat bot should enter for that user after the pattern is applied. It is allowed to be an arbitrary string and can have variables in it. These will be interpolated when the pattern is applied.
Response
This is the text that the chat bot will post back to the thread in question in response to a user request. It is a string and can have variables. In addition, to variables bound from the Request Expression, it can make use of $REMOTE_RESPONSE which has the string returned from the Bot url call (if there was one), and it can make use of $USER_NAME, the name of the user that the post was in response to.
X