Synbot Plugin Tutorial - interface to Syn Bot Software

Step 4 : Manage the dialog with the Bot

Starting a Bot session

A bot session can be started : . By clicking the Start Bot Button on the plugin Main Window Bot session is started with the userid input in the userid field or with the default userid set in the plugin configuration form if the userid field is empty. . In EZ Scripts

Botstart("userid")

where userid is the userid for the bot session If userid is not entered Botstart() - the default userid set in the plugin configuration form will be used . Or for use in Blockly

$Botuser= "userid"
ControlCommand("Synbot Plugin", Start)

Once the Bot started , you have access to : . Input Query Text Field with the Send Button in order to enter and send a text query to the bot. . Stop Button in order to stop the session with the bot . Save Context Button in order to save the session Context for the userid - see next in step 5

User-inserted image

It can be only started when Bot Twitter stream is set in configuration form by sending from a twitter account a private message to the Bot twitter account. Content of private message to start the Bot is the value of Bot Start Message which can be set in plugin Configuration Form.

Console is displaying user messages sent to the Bot and responses received from the Bot User name linked to the session userid and Bot Name are used for display message prefixing. Here "Jean Luc" for User Name and "Maya" for Bot name

You can change Bot name in setting Synbot BOT variable Name to the value you wanted. And so for User Name in setting Synbot USER variable Name to the value you want. (See later in Step 5 for working with Synbot variables)

The EZ Builder variable $Botstarted is set to 0 when there's no bot session started and to 1 when bot session is started.

Querying the Bot with a text message

Once a bot session is started , you can query the Bot with text messages. This text messages will be analysed by the Bot Engine depending on the SIML files of the Project and a message Bot response will be returned.

There are several ways to query the Bot : . Enter the query message in the plugin Query Text Field and press Send Button or Return Key . Send the query message as a private message from a twitter account to the bot twitter account . In EZ Builder scripts :

Botquery("query message") 

Or

$botusermessage= "query message"
        ControlCommand("Synbot Plugin", Query)

Before sending the query message to the SYN Bot framework - some filtering is done by the plugin to suppress unwanted characters (, ; ! ? CR/LF multiple contigous spaces ) If language used is english , possessive apostrophs if any in the message are transformed ("The Mary's dress" is transformed to "The dress of Mary") This transformation can be unchecked in plugin configuration form. Is limited to One word before and after contraction - For example "Blue Bird's feather" will be incorrectly transformed in "blue feather of bird" and not in "feather of blue bird" "Bird's blue feather" will also be incorrectly transformed in "blue of bird feather" instead of "blue feather of bird" ......

Bot response message is splitted in 2 parts : . A text message which can be (depending on plugin configuration options) speaked or not and sent to PC or EZB speakers ( EZB Command Say or SayEzb will be invoked by the plugin) . A Command message containing EZB commands which will be invoked by the plugin

Text message Bot Response can be stored in an EZ Builder Variable which name can be set and changed in plugin configuration form.

User-inserted image

In the above Example : The query message was "move forward at full speed" Text Bot response message : 'I move forward" EZB commands invoked : SetSpeed(255 , 255) then Forward() the "|" character is just a CR/LF separator and is changed to CR/LF (As in an EZ Buider Script) when invoking the script.

Formatting the Bot response message in SIML files

When the query message match a Pattern defined in a Model Block , Bot response is created in the Response Block. Response block result is sent back to the plugin. Only the last response (in case of [GOTO] redirections) is sent back to the plugin.

To avoid lost of multiple responses due to use of [GOTO] tag , SIML files Bot responses must be set as value of a USER variable named bot_event_response

[User xml:space="preserve" Think:Set="bot_event_response"]DURATION CANNOT BE SET FOR THIS MOVEMENT]/User>]

If a response is returned by the tag, this response will be also sent back to the plugin. The query result will be the concatenation of this response and of the value of the bot_event_response USER variable. This variable is reinitit for each new query.

In order to be able to include EZ Commands in the Bot response, Response format must be coded in SIML as follow : Text messageScript 1Script 2 or Text messageScript 1 the character is only a separator.

A script is a sequence of EZ Buider commands as in an EZ Builder script , each command separated by the | character - equivalent to the CR/LF in an EZ Builder script. 2 scripts can be specified and invoked asynchronously in the plugin ( 2 executors are used )

in the example above , the Bot response message was formatted in SIML : I move forwardSetSpeed(255 , 255)|Forward() the SIML code

[Model]
  [Pattern]move forward at full speed[/Pattern]
  [Response]
   I move forwardSetSpeed(255 , 255)|Forward()
  [/Response]
[/Model]

or better

Model]
  [Pattern]move forward at full speed[/Pattern]
  [Response]
     [User Think Set="bot_event_response"]I move forwardSetSpeed(255 , 255)|Forward()[/User]  
  [/Response]
[/Model]

Stopping the Bot session

The bot session can be stopped : . By clicking the Stop Bot Button on the plugin Main Window . By sending a private message from a twitter account to the bot twitter account. Content of private message to stop the Bot is the value of Bot stop Message which can be set in plugin Configuration Form. . In EZ Scripts :

Botstop()

Or

ControlCommand("Synbot Plugin", Stop)

Context of BOT variables values and USER variable values for the userid is saved.

Example of linking to Bing Speech RecognitionControl

In you want that the Bing Speech Results will be used for querying the Bot , configure the "script to execute for each phrase detected " in Bing Speech Recognition plugin configuration form.

User-inserted image

if (!$botstarted)
  ControlCommand("Synbot Plugin", Start)
  sleep(1000)
endif
$botusermessage = $BingSpeech
ControlCommand("Synbot Plugin", Query)

What is your temperature is recognized

User-inserted image

Using Twitter

You can start stop and send query to the bot from a twitter account in sending private messages to the bot twitter account. Bot Twitter account must be configured and authorized in configuration form.

User-inserted image


ARC Pro

Upgrade to ARC Pro

With Synthiam ARC Pro, you're not just programming a robot; you're shaping the future of automation, one innovative idea at a time.