Synbot Plugin Tutorial - interface to Syn Bot Software

Step 10 : New SIML Tags added in the Plugin - Wikipedia Search , Translate , Twitter , Mail , .......

WIKIPEDIA Search

[x:Wikipedia] tag

With [x:Wikipedia] tag , you can search on Wikipedia either with MediaWiki API , either Opensearch API or Query API. Query API give more detailed results than Opensearch API.

Syntax is [x:Wikipedia Search="Searched expression" Filter="No" /] for Opensearch API [x:Wikipedia Search="Searched expression" Action="query" Filter="No" /] for Query API

Querying language is the default language configured in the plugin configuration form. Number of found results is returned and can be tested. In case of network access error - 0 is returned. Filter parameter is an option to filter or not wikipedia response content - implicit is filter activated - if you don't want you need to specify Filter="No". Filtering suppress all text within () in the response and entries ending with "refers to:"

[User Set="Tempcount"][x:Wikipedia Search="{Bind Match:1}" /][/User]

Results found can be accessed in SIML User variables (5 results maximum are returned) - variables Result_1 Result_2 Result_3 Result_4 and Result_5

Bot querying models examples can be found in "Search Wikipedia SIML" file. Or you can try the batch test file Testwikien.txt

Here an example of Dialog :

User-inserted image

Translate

[x:Translate] tag

With [x:Translate] tag , you can translate a text from a source language to another language using in background the Microsoft Bing Translate API. You need first to subscribe free to the TRANSLATE_TEXT service in your Microsoft Azure Dashboard. Free plan include 2 million characters per month. You get an API Key. Paste this API key in the Text Translate API Key input field of Synbot plugin configuration form and Save.

Syntax is [x:Translate From="Source Language Code" To="Language to translate code"]Text to translate[/x:Translate] [x:Translate From="Source Language Code"]Text to translate[/x:Translate] [x:Translate To="Language to translate code"]Text to translate[/x:Translate] [x:Translate]Text to translate[/x:Translate]

When the From parameter is omitted , source language for the text to translate will be automatically detected by the service. When the To parameter is omitted , language to translate code will be automatically set with code of language used in the session - value of SIML User Variable Userlanguage Language codes are those used and supported by the Microsoft TRANSLATE_TEXT API.

Tag will return the translated text value. SIML User variable Languagedetected will be set with code of the source language detected. SIML User variable FlagOKtranslate will be set to True or False depending on the translation was successful or not (In case not successful , some error messages will be display in EZ Builder log console).

Exemple used in the Vision Description Query Model - File EZ Robot Request-Queries.siml

[Var Set="Visiondescription"][x:Translate][Var Get="Visiondescription" /][/x:Translate][/Var]

Twitter interface

[x:Twitter] tag

With [x:Twitter] tag , you can publish a tweet on the twitter bot account or send a twitter private message to a twitter user. You need first to sign up for a specific twitter account for your robot and to configure the twitter stream input parameters in the Synbot plugin Configuration Form. (See advanced plugin configuration options before)

Syntax is [x:Twitter Function="SEND" To = "Twitter user name"]Text to Send[/x:Twitter] [x:Twitter Function="PUBLISH" File="Full Pathname for file attachment"]Text to Send[/x:Twitter]

If file parameter is omitted , no attachement will be published in the tweet message. Tag will return True or False depending on the action was successful or not (In case not successful for example incorrect pathname for attachment, some error messages will be display in EZ Builder log console). File attachment is not today supported with the SEND function.

For Publish function , as it is asynchronous , a SIML Event will be raised when the operation is completed (succesfully or not) : Event names are RETURNFROMTWEETPUBLISHINGOK if successful and RETURNFROMTWEETPUBLISHINGKO if not successful. Models can be included in SIML files to define what to do when these events are raised.

For example:

[Var Set="Flagerr"][x:Twitter Function="PUBLISH" File="{Bind Var:filename}"][User Get="Textentered" /][/x:Twitter][/Var]
[Var Set="Flagerr"][x:Twitter Function="SEND" To="{Bind Var:Twittername}"][User Get="Textentered" /][/x:Twitter][/Var]
[If Var="Flagerr" Value="True"][User Set="bot_event_response" xml:space="preserve"][Random Get="{Bind Var:TempOKmess}" /][/User][/If]
[If Var="Flagerr" Value="False"][User Set="bot_event_response" xml:space="preserve"][User Get="NotOKmesssaved" /][/User][/If]

See detailed example in SIML File "EZ Robot request - Bot Response Message building"

Send mail interface

[x:Mail] tag

With [x:mail] tag , you can send a mail to an email adress , with or without an attachment file. You need first create an email address and account for your robot and to configure the Bot email parameters in the Synbot plugin Configuration Form. (See advanced plugin configuration options before)

Syntax is [x:Mail Function="SEND" To="email adress" File="Full Pathname for file attachment" Subject="subject text for the email"]Text to Send[/x:Mail]

If file parameter is omitted , no attachement will be attached to the message. If subject parameter is omitted , message subject will be empty. if function parameter is omitted , implicit SEND function will be used. Tag will return True or False depending on the action was successful or not (In case not successful for example incorrect pathname for attachment, some error messages will be display in EZ Builder log console).

As SEND function is asynchronous , a SIML Event will be raised when the operation is completed (succesfully or not) : Event names are RETURNFROMMAILSENDOK if successful and RETURNFROMMAILSENDOK if not successful. Models can be included in SIML files to define what to do when these events are raised.

For example:

[Var Set="Flagerr"][x:Mail Function="SEND" To="{Bind Var:Mailaddress}" Subject="MAYA INFO" File="{Bind Var:filename}"][User Get="Textentered" /][/x:Mail][/Var]

See detailed example in SIML File "EZ Robot request - Bot Response Message building"

Find last file created or modified in a Windows folder

[x:Findfile] tag

With [x:Findfile] tag , you can retrieve name of the last created or modified file in a windows folder. This tag can be used for example to retrieved file name for the last photo or video taken by your robot in order to send or publish it.

Syntax is [x:Findfile Function="LAST" Filter="Filter for file to retrieve"]Path of folder to Search[/x:Mail]

Filter parameter value can be any file search filter - several filters can be set separated by |. Example Filter=".jpg|.png|*.bmp" will retrieve only files with jpg, png and bmp extension. If filter parameter is omitted , no filter will be apply. Tag will return either name of file retrieved or empty value if no file found or if error occured.

For example:

[Var Set="filename"][x:Findfile Filter="{Bind Var:Filter}"][Bot Get="EZmediafolder" /][/x:Findfile][/Var]
[If Var="filename" Value=""][Var Set="Flagerr"]1[/Var][/If]

See detailed example in SIML File "EZ Robot request - Bot Response Message building"

Syntactic analysis and control for a free text with structure [preposition] [article] [name]

[x:Decodeattribute]

With [x:Decodeattribute] tag , you can do a syntactic analysis and control for a free text part. Syntactic form supported is [Prefix] [Preposition] [Article] [Name] NOTE THAT THE TAG IS A BETA VERSION WHICH CAN HAVE MANY UPDATES IN NEXT VERSIONS Several types of decoding and control can be specified depending on value of function parameter:

"F" - No decoding and no control done on the text except searching if text exist or in the plural form SIML Map name_pluriels_[language code] If we detect that text is a plural form in this map - the singular entry will be returned and genre variable will be set to P as Plural

"0" or "1" - Text decoding is done - if "1" control is done with preposition and article authorization parameters Search and suppressing of Prefix if Prefix parameter is set. Search for preposition : as (comme) on (sur) to (à ,....) of (de, ....) about (au sujet, sur le sujet) during (pendant) Search for article : a an the - un une le la les, ...

At the end of decoding steps - SIML variables are set : . decodearticle with the article found (Empty if no article, A, THE, P(Plural article in french) . decodepreposition with the preposition found (Empty if no preposition, TO, OF ,OF, AS, ABOUT) . decodegenre with the genre found depending of article and existing or not of a plural form in SIML Map name_pluriels_[language code] genre can be F(eminine) M(asculine) N(euter) I(not determined) or P(lural) . decodename with the singular form of [name] after decoding . decodenamewithde decodename form preceded by OF (de) preposition . decodenamewitharticle decodename form preceded by the corresponding to genre article

Control of text decoding results is after done dépending on value of Article and Preposition Parameters. . Preposition parameter is a word of 10 characters with value F(false) or T(rue) - T(rue) meaning authorized. - Char 1 authorize or not text structure with no preposition. - Char 2 authorize or not text structure with type TO preposition. - Char 3 authorize or not text structure with type OF preposition. - Char 4 authorize or not text structure with type AS preposition. - Char 5 authorize or not text structure with type ON preposition. - Char 6 authorize or not text structure with type ABOUT preposition. - Char 7 authorize or not text structure with type DURING preposition. - Char 8 to 10 are reserved for future use . Article parameter is a word of 4 characters with value F(false) or T(rue) - T(rue) meaning authorized. - Char 1 authorize or not text structure with no article. - Char 2 authorize or not text structure with type AAN article. - Char 3 authorize or not text structure with type THE article - Char 4 authorize or not text structure with type PLURAL article.

Tag return True or False dépending the authorization and of the text decoding results. If Preposition parameter is omitted , implicit value is all authorized (TTTTTTTTTT). If article parameter is omitted , implicit value is all authorized (TTTT).

"2" - Same as 1 but with an additionnal control with the content of SIML map whose name is specified in the Map genreparameter. Structure of this control map for each entry must be as

[MapItem Content="fr|lion" Value="%MM lion" /]

Entry Key is codelanguage|decodename and value content structured with char 1 % , char 2 genre of name , char 3 genre. For example for a person name John, Entry will be "en|John" and value "%NM John" - as genre of name is N(euter) and person genre is M(asculine).

Tag will return F(alse) if key for codelanguage|decode name is not existing in the control map and when there are inconsistancies between genre decoded in text and genre values in the control map entries.

If Control is OK , value SIML variables decodegenre and decodegenreneutral are set with genre of name and genre found in the control map. This kind of control is not critical in english language but is for french. If you know for example that "lion" is a Masculine Genre Name , you cannot authorize text structure with "la lion" where presence of the "la" article induce a Feminine genre.

If function parameter is omitted , implicit value will be set to F.

Value of SIML Variable decodenameres is in any case set to initial text with some transformations in order to be used to build bot responses Examples Text: "of the lion" will lead to decodepreposition = OF, decodearticle = THE decodename = lion, decodegenre = I Text: "about John" will lead to decodepreposition = ABOUT, decodearticle = "" decodename = John, decodegenre = I

Tag syntax : [x:Decodeattribute Type="Decoding type" Article="Article authorization word" Preposition="{Preposition authorization word}" Mapgenre="name of control SIML Map"]Text to decode[/x:Decodeattribute]

For example :

[Var Set="flagok"][x:Decodeattribute Type="{Bind Var:flagsfreeattributedecode}" Article="{Bind Var:authoarticle}" Preposition="{Bind Var:authopreposition}" Mapgenre="genre_name"][User Get="freeattribute" /][/x:Decodeattribute][/Var]

Control Text operations

[x:Textcontrol]

With [x:Textcontrol] tag , you can do some control on a text string - Numeric , date format , .....

Syntax is [x:Textcontrol Type="Control type mnemonic"]text string[/x:Textcontrol] Return True if one of the control is successfull or False if all controls are not successful. Control type is a text word giving which kind of controls to do. If Character 1 if T(True) - control if text string is or not a numeric integer will be done. Next characters are reserved for future use (Other controls) Mnemonic values are specified in map typecontrol_freeattribute

[Map Name="typecontrol_freeattribute"]
    [MapItem Content="NO" Value="FFFFFF" /]
    [MapItem Content="NUMERIC" Value="TFFFFF" /]
    [MapItem Content="FULLDATE" Value="FTFFFF" /]
    [MapItem Content="NUMERICORFULLDATE" Value="TTFFFF" /]
  [/Map]
[Var Set="Flagok"][x:Textcontrol Type="NUMERIC"][Var Get="namekey" /][/x:Textcontrol][/Var]

Syntactic Text operations

[x:Syntax]

With [x:Syntax] tag , you can do some Syntactic analysis or replacement on a text string

Syntax is [x:Syntax Function="Action Type"]Input text string[/x:Syntax] Tag Result is modified text string depending on Action Type.

Action Type replacepossessiveadjective do a syntactic replacement of possessive adjectives found in the input string - in english "My" is transformed in "Your" and "your" in "My" and the same type of replacement in french

[Var xml:space="preserve" Set="message_result"][x:Syntax Function="replacepossessiveadjective"][Var Get="message_result" /][/x:Syntax][/Var]

Text operations

[x:Textop]

With [x:Textop] tag , you can do some operations on a text string - Substring - replacing characters - splitting

Syntax is

[x:Textop Function = "function" Delimitor = "Delimitor" At = "position" Length = "length" Value = "Value" ]text string[/x:Textop] Return value depending on function :

Function = "Substring" implicit value - At and Length parameter Mandatory - Return Substring of input text at Position with Length Length

Function = "Split" - Delimitor parameter Mandatory - Character delimitor - Return Number of spliited element Splitted text can be retrieved in SIML variables ressplit_n

Function = "Replace" - Parameter value is mandatory for replacing text and At for position - Length is optionnal(Implicit length of replacing text) Return Text modified with replacing text at position At on length characters

[Var Set="Nbsplit"][x:Textop Function="Split" Delimitor="|"][Match /][/x:Textop][/Var]


ARC Pro

Upgrade to ARC Pro

With ARC Pro, your robot is not just a machine; it's your creative partner in the journey of technological exploration.