Step 7 bis : Working with Bot Emotions
Emotions can be configured in SIML File EMOTIONML in Settings Folder.
Setting the value of Bot Emotion :
During a bot session , Bot emotion can be set either in SIML Bot files or in EZ Builder scripts. Variable value type is always a string type. If the variable doesn't exit , it is created.
In SIML : [BotEmotion ID="Sad" /] In EZ Builder Scripts :
Setbotemotion("Emotion ID")
or for using in Blockly
$Botemotion = "Emotion ID"
ControlCommand("Synbot Plugin", Setbotemotion)
Getting the value of Bot Emotion :
In SIML : [BotEmotion Get="id" /] In EZ Builder Scripts :
Gettbotemotion()
or for using in Blockly
ControlCommand("Synbot Plugin", Getbotemotion)
Result value is returned in $Botemotion EZB variable
Synbot plugin Configuration:
Whenever Bot Emotion value is changed , value of $Botemotion EZB variable is updated. You can also in plugin Configuration Form specify a default init value for Bot Emotion which will be set when you start the Bot Session. if the configured default Emotion is Empty , Bot Emotion will be saved and restore from one session to another for the same User , if the configured default Emotion is Empty.
You can also configure an EZ Builder Script which will be executed every time Bot emotion Changed.
Framework integration:
In order to demonstrate use of Bot Emotion , framework example include some new features
A new [Verb] Show Yourself in order to be able to set Bot Emotion - which is a [free attribute] Verb bbId and Verb AuthoId are set to "EMOTION" Map Emotion is used to control free attribute (3rd word in content is link to the emotion ID)
[Map Name="Emotion"]
[MapItem Content="fr|triste" Value="%1M EMPTY sad" /]
[MapItem Content="en|sad" Value="%1M EMPTY sad" /]
[MapItem Content="fr|en colère" Value="%1M EMPTY angry" /]
[MapItem Content="fr|furieux" Value="%1M EMPTY angry" /]
[MapItem Content="fr|furax" Value="%1M EMPTY angry" /]
[MapItem Content="fr|en rage" Value="%1M EMPTY angry" /]
and Map Emotion_lib is used to retrieve a label corresponding to Emotion ID and language used
[Map Name="Emotion_lib"]
[MapItem Content="fr|0|sad" Value="triste" /]
[MapItem Content="en|0|sad" Value="sad" /]
[MapItem Content="fr|0|angry" Value="en colère" /]
[MapItem Content="en|0|angry" Value="angry" /]
[MapItem Content="fr|0|bored" Value="ennuyé" /]
[MapItem Content="en|0|bored" Value="bored" /]
Action for EMOTION Workflag has been created with lauching of an EZBuilder Script
[Case Value="EMOTION"][Goto xml:space="preserve"]XXXXXXXCHANGEEMOTION[/Goto][Var Set="EZscript"]Bot Emotion Change Action[/Var][/Case]
code] [Model] [Pattern]XXXXXXXCHANGEEMOTION[/Pattern] [Response xml:space="preserve"] [Think] [Var Set="Messchangedemotion"]Messchangedemotion_[User Get="Userlanguage" /][/Var] [Var Set="emotionname"][Text WordAt="3"][User Get="Contentmapfree" /][/Text][/Var] [!--Change Bot Emotion--] [BotEmotion ID="{Bind Var:emotionname}" /] [Var Set="Messchangedemotion"]Messchangedemotion_[Var Get="emotionname" /][User Get="Userlanguage" /][/Var] [!--Test if a specific message exist for the bot emotion id--] [Var Set="Emotionanswerexisting"][Random Get="{Bind Var:Messchangedemotion}" /][/Var] [!--If not take the default message--] [If Var="Emotionanswerexisting" Value=""] [Var Set="Messchangedemotion"]Messchangedemotion[User Get="Userlanguage" /][/Var] [/If] [!--Message will be said with waiting--] [Var Set="Mess1replace" xml:space="preserve"][Random Get="{Bind Var:Messchangedemotion}" /][/Var] [/Think] [/Response] [/Model]
Some news models have been integrated in Bot Dialogs SIML file , in order to be able to query on Bot Emotion.