In SimpleOne, REST Bot Engine allows implementing connectors with third-party services (such as messengers, AI systems, and so on) to solve various business tasks depending on the demand. As an example: when an incident is created, the responsible group receives notification to the specified messenger with the subject specified.
A bot type is a connecting element for bot methods and bot instances. When created, you can easily specify which bots can use configured methods, and vice versa.
To create a new bot type, please complete the steps below:
In this section, you can configure REST API methods provided by the third-party system to interact with it. Bot methods are bound with routing rules and routing parameters.
To create and configure a new bot method, please complete the steps below:
Bot methods form fields
Field | Description | ||
---|---|---|---|
Name | Specify a method name. | ||
URL Suffix | Addition to the request URL. It takes a relative path changing depending on the different methods. Full request URL is concatenated out of the constant part specified in the URL field of the bot instance and of this URL suffix. | ||
Request method | Request method, for example, GET or POST. To add more request methods, use the Configure field functionality:
| ||
Bot type | By specifying a bot type, you can choose which bots can use this method. This field references the Bot Type (sys_bot_type) table. | ||
State parameter | In this parameter, you can define whether the request was successful or not. It stores a string the response body must return in order for the request to be considered successful. If not filled, the request will be always considered as successful (except for the errors on the instance). For example: | ||
Headers | In this field, you can specify the method headers if necessary. Variables usage is acceptable (variables must be angle-bracketed). In the example below, the token from the bot instance will be substituted instead of the variable:
| ||
Body | The body of the request. Variables usage is acceptable (variables must be angle-bracketed). In the example below, the message is sent out to the messenger channel defined by the variable <routing_parameter_0> and routed to the thread in this channel defined by the variable <routing_parameter_1>. The content of this message is defined by the <content> variable. These variables should be defined in the Bot Routing Rule (will be described further below).
|
Create a bot instance to perform integration further (use bot methods, routing rules).
To create a new bot, please complete the steps below:
Field | Description |
---|---|
Name | Specify a bot name. |
Bot type | By specifying a bot type, you can choose methods this bot can use. This field references the Bot Type (sys_bot_type) table. |
Token | Specify a token if the bot has an authorized access to third-party service. This token should be provided by API provider. |
URL | An URL for performing requests. This URL part is an constant one, unlike the URL suffixes specified for every bot methods. |
Routing parameters are used in the bot routing rules, they allow to be more specific.
The main purpose of this functionality is configuring correlations between column value upon a bot routing rule triggering and a column value used in the request body.
To create a routing parameter, please complete the steps below:
Field | Description | |
---|---|---|
Bot method | Specify the method related to this routing parameter. | |
Column value | Specify a column value for the additional routing. | |
Parameter value | Specify the value for the parameter that will be substituted to the request body instead of the <routing_parameter> variable for the record having the value defined in the Column Value field in the specified column.
|
Bot routing rules table contains conditions and rules to trigger; when conditions are met, the trigger performs a request to the external service. The request history can be found in the Related Lists area for every record.
To create a new bot routing rule, please complete the steps below:
Field | Description | |
---|---|---|
Name | Specify a routing rule name. | |
Active | Select this checkbox to make the rule active or inactive. | |
Bot | Specify the bot for which you need to configure the routing rule. This field references the Bot (sys_bot) table. | |
Bot method | Specify a bot method related to this routing rule. This field references the Bot Method (sys_bot_method) table. | |
Business rule | After specifying relevant bot and bot method, the relevant business-rule is generated and filled after record saving; it is based on the parameters defined in these essences; this business-rule is to trigger on events in the system and meeting the rule conditions.
| |
Table | Specify the table on which the routing rule will be working on. | |
Routing by Column | The multi-selection field referencing to the routing parameters.
| |
Use Response | Select this checkbox in case of processing of designated REST response is needed. The Use Response tab appears. | |
When to Run tab | ||
Action Insert | Select this checkbox if the routing rule should perform actions when inserting a new record. | |
Action Update | Select this checkbox if the routing rule should perform actions when updating existing record. | |
Action Delete | Select this checkbox if the routing rule should perform actions when deleting existing record. | |
Order | Specify the routing rule processing order. | |
Condition to run | Create a condition to meet before the routing rule is triggered. Use the Condition Builder to build a filter that fits your needs. You can create complex AND and OR filters, more than one condition in one filter.
| |
Content tab | ||
Advanced content | Select this checkbox in case if the content transferred to the <content> variable must be dynamic. When checked, the Content Script field appears. Enter your script there and in the end return the content string value using the return directive. | |
Content Script | Specify content that should be transferred to the <content> variable. The content may be static (some text or instruction) or dynamically generated. To generate content dynamically, select the Advanced content checkbox and enter your script into the Content Script field. | |
Use Response tab | ||
Response parameter | Specify a path to the interested response parameter from the response body. Example: ts.user.id | |
Write to Table | Specify a table where to write down the parameter. | |
Write to Column | Specify a table column where to write down the parameter. | |
Source Mapping Column | The table column where the routing rule triggers. Specify Source Mapping Column and Target Mapping Column fields in case if the resulting table is another one than the table where the request triggers. | |
Target Mapping Column | The table column to put the request result. How it works: The request result is recorded into the Write to Table table record where the values in the Source Mapping Column and Target Mapping Column columns match. It means that value in the Source Mapping Column column of the Write to Table table should match the value of the Target Mapping Column of the Write to Table table. If the values do not match, then the error is thrown and registered in Bot Request History. |
In there, the bot requests history to third-party services is stored.
To check out the history, please complete the steps below.
Field | Description | |
---|---|---|
Record ID | The record ID on which the request has been generated. | |
State | The request state. Available options:
| |
Bot Routing Rule | Bot routing rule on which the request has been generated. | |
URL | URL of the request specified. | |
Method | Method of the request specified. | |
Headers | Headers of the request specified. | |
Body | Body of the request specified. | |
Response | This field contains request response useful for debug or troubleshooting. In there, you can find both the errors returned by third-party REST API, and the errors arisen on the server-side when making or sending a request. |
Consider an user case: you need to implement direct notification via messengers.
Input data you have:
Employee name | John Doe |
---|---|
Employee's messenger ID | #R11F0G2SD |
Employee's sys_id on the SimpleOne instance | 160707678680781750 |
Create a notification method. For this, create a record in the Bot Method (sys_bot_method) table as described in this article above. Populate the Body field with the value below:
{ "channel": "<routing_parameter_0>", "text": "<content>", "as_user": "true", "link_names": "true" } |
In this example, the "channel": "<routing_parameter_0>" bundle specifies that the channel key will substitute the routing_parameter_0 parameter when the request is sent.
Create a notification rule. For this, create a record in the Bot Routing Rule (sys_bot_routing_rule) table.
In our user case, the trigger will be the new record creation in the Task table.
Routing parameters are defined in the Routing by Column field of the related Routing Rule record and used for sending messages. You can specify more than one parameter in this field numbered starting from 0 (see example below):
{ "channel": "<routing_parameter_0>", "thread": "<routing_parameter_1>", "text": "<content>", "as_user": "true", "link_names": "true" } |
To specify method content more precisely, use fields located in the Content tab of the Bot Routing Rule record.
Avoid using double quotes (" ") in bot routing rule content. Also, it is not allowed to put an odd number of backslashes in a row. If content is generated by a script in the Content Script field, then escape quotes and replace single backslashes (for example, by a slash) before returning values. The code example below contains regular expression implementing necessary substitutions:
|
Create a routing parameter. For this, create a record in the Routing Parameter (sys_routing_parameter) table. Fill in the field as described below:
Field | Description | Value |
---|---|---|
Bot method | Reference to the method using current routing parameter to send a message to employee. | send.message.to.employee |
Column value | This value is searched for match by the bot routing rule. In our example, it's employee's ID on SimpleOne instance. | 160707678680781750 |
Parameter value | This parameter value is used in body of the method specified in the Bot Method field. In our example, it's an employee's ID in his messenger. | #R11F0G2SD |