Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In SimpleOne, REST Bot Engine allows implementing connectors you to in 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 For example, when an incident is created, the responsible group receives notification to the specified specific messenger with the specified subject specified.

How to implement integration

To integrate with the third-party service

, complete the following steps:

  1. Configure the third-party service Provide the preparations on the other side (register if needed, get an authorization token, check the API documentation).
  2. Create a bot type record.
  3. Configure the REST methods used to interact with the third-party service.
  4. Configure a bot instance.
  5. Configure Set up the routing parameters.
  6. Configure Set up the routing rules. 
Creating

Create a bot type


A bot type is a connecting element for the 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:

  1. Navigate to Bots API → Bot Types.
  2. Click New and fill in the form, specify a Name for a bot type.
  3. Click Save or Save and Exitexit to apply the changes.
Configuring

Configure REST bot methods


In this section, you can configure Configure the REST API methods provided by the third-party system to interact with it. Bot The bot methods are bound with to the routing rules and routing parameters. 

To create and configure a new bot method, please complete the following steps below:

  1. Navigate to Bots API → Bot Methods.
  2. Click New and fill in the form.
  3. Click Save or Save and Exitexit to apply the changes.

Bot methods form fields

FieldMandatoryDescription
NameYSpecify a method name.
URL SuffixNSpecify a relative path in addition 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 The full URL of the request consists of the constant part specified in the URL field of the bot instance and of this URL suffix.
Request methodRequest N method, for example, GET or POST.

Specify the request method. Available options:

  • GET 
  • POST 
Expand
titleAdd more request methods

To add more request methods, use the Configure field

 functionality

functionality:

  1. Right-click
on
  1. the field title to get the context menu.
  2. Select
the
  1. Configure field
item
  1. .
Navigate to
  1. In the Related Lists area, select the Choice tab.
  2. Click New and fill in the
form
  1. fields:
    1. Table
-
    1. specify the table this method is related to (generally, it is a Bot Method table).
    2. Column
-
    1. this field is populated automatically and indicated a parent column for the record.
    2. Title
-
    1. specify the title for the record (for example, PUT).
    2. Language
-
    1. specify the language for your choice option (in this case, the default value is 'en').
    2. Value
-
    1. specify the relevant value for this choice option (in the example above, it should be 'put').
    2. Order
-
    1. specify the order for this choice option to display in the choice list.
  1. Click Save or Save and
Exit
  1. exit to apply the changes.


Bot typeNSpecify the By specifying a bot type , you can choose which bots can that can use this method. This field references the Bot Type (sys_bot_type) table.
State parameterN

Define the parameter that shows In this parameter, you can define whether the request was is successful or not. It The field stores a string the response body must return in order for the request to be considered successful. If not filledleft empty, the request will be is always considered as successful (except for the errors on the instance).

For exampleExample:

Image RemovedImage Added

HeadersN

Specify In this field, you can specify the method headers if necessary. Variables usage is acceptable (variables must be angle-bracketed)in the angle brackets are allowed. In the following example below, the variable substitutes the token from the bot instance will be substituted instead of the variable:

Code Block
languagexml
themeEclipse
titleHeader
authorization:Bearer <token>; Content-Type:application/json


BodyN

Specify the The body of the request. Variables usage is acceptable (variables must be angle-bracketed)in the angle brackets are allowed. In the following example below, the message is sent out to the messenger channel defined by the variable <routingvariable <routing_parameter_0> and routed to the thread in this channel defined by the variable <routingvariable <routing_parameter_1>. The content of this message is defined by the <content> the <content> variable. These variables should be defined in the Bot Routing Rule (will be described further below).


Code Block
languagexml
themeConfluence
titleBody
linenumberstrue
{
"channel": "<routing_parameter_0>",
"text": "<content>",
"thread_ts": "<routing_parameter_1>",
}


Info

The numeration of the routing parameters numeration is started starts with 0.

 

Configure a bot instance


Create a bot instance to perform continue the integration further process (use bot methods, routing rules).

To create a new bot, please complete the steps below:

  1. Navigate to Bots API → Bots.
  2. Click New and fill in the form.
  3. Click Save or Save and Exitexit to apply the changes.

Bot form fields

FieldMandatoryDescription
NameYSpecify
a bot
the bot name.
Bot type
By specifying a bot type, you can choose methods
YSpecify the bot type. It includes methods that this bot can use.
This field references the Bot Type (sys_bot_type) table.
TokenNSpecify a token if the bot has
an
authorized access to a third-party service. This token should be provided by the API provider.
URL
An
YSpecify a URL for
performing
making requests. This part of the URL
part
is
an constant one
permanent, unlike the URL suffixes specified for
every
each bot
methods
method.
Configuring

Configure routing parameters


Routing The routing parameters are used in the bot's routing rules , they allow to be make them more specific. 

The main purpose of this functionality is configuring correlations between to set up a correlation between a column value upon a when the bot routing rule triggering is triggered, and a column value used in the request body.

To create a routing parameter, please complete the steps below:

  1. Navigate to Bots API → Routing Parameters.
  2. Click New and fill in the form.
  3. Click Save or Save and Exitexit to apply the changes.

Routing Parameter form fields

FieldMandatoryDescription
Bot methodYSpecify the method related to this routing parameter.
Column valueYSpecify a column value for
the
additional routing.
Parameter valueN

Specify the value for the parameter that

will be substituted to the request body instead of the

substitutes the <routing_parameter> variable in the request body for the record

having

that has the Column value

defined in the Column Value field in the

 in the specified column. 

Info

You can create more than one parameter

, as many as you need. In this case, they

. They should be numbered starting from 0:

routing_parameter_0

routing_parameter_1

Configuring bot


Configure bot routing rules 
Anchor
routing rules
routing rules


The Bot routing rules table contains conditions and rules to trigger; when conditions are met, the trigger performs executes a request to the external service. The request history can be found is in the Related Lists area for every each record.

To create a new bot routing rule, please complete the steps below:

  1. Navigate to Bots API → Bot Routing Rules.
  2. Click New and fill in the form.
  3. Click Save or Save and Exitexit to apply the changes.
FieldMandatoryDescription
NameYSpecify a routing rule name.
ActiveNSelect this checkbox to
make
activate the rule
active or inactive
.
BotYSpecify the bot for which you need to configure the routing rule.
This field references the Bot (sys_bot) table.
 
Bot methodYSpecify 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
N

The business-rule is generated

and filled

automatically after

record saving; it

the record is saved. It is based on the parameters defined in

these essences; this business-rule is to trigger on events  in the system and meeting

the Bot and Bot method fields. This business rule triggers events in the system that meets the rule conditions.

Info

When updating the routing rule, the business rule updates automatically.

When deleting the routing rule, the business rule deletes automatically.


TableYSpecify the table on which the routing rule
will be working
works on.
Routing by
Column
columnN

Specify the columns that refer to

The multi-selection field referencing to

the routing parameters.

Info

When

selecting columns, in case if

you have to match more than one routing parameters with relevant columns,

please keep in mind, that columns

the columns should be stated in this field

have to be

in the same order

that

as the routing parameters in the request body.


Use ResponseNSelect this checkbox
in case of
when the processing of the designated REST response is needed.
The
When selected, the Use Response tab appears on the form.
When to Run tab
Action InsertNSelect this checkbox if the routing rule should perform actions when inserting a new record.
Action UpdateNSelect this checkbox if the routing rule should perform actions when updating existing
record
records.
Action DeleteNSelect this checkbox if the routing rule should perform actions when deleting
existing  record
existing records.
OrderY

Specify the routing rule processing order.

Condition to runN

Create a condition to meet

before

to trigger the routing rule

is triggered

.

Use the 

Condition Builder to

condition builder to build a filter that

fits your

you needs.

 You

You can create complex AND and OR filters

, more than one condition in one filter

.

 

Info

An empty condition always

returns '

returns true

'

.


Content tab
Advanced contentNSelect this checkbox
in case
if the content transferred to the <content> variable must be dynamic. When
checked
selected, the Content Script
field appears
field appears. 
Content scriptNSpecify the dynamic content that should be transferred to the <content> variable. Enter your script
there
and
in the end
return the
content
string value of the content using the return directive.
Content
Script
NSpecify
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
content that should be transferred to the <content> variable.
Use Response tab
Response parameterY

Specify a path to the

interested

necessary response parameter from the response body.

Example: ts.user.id

Write to
Table
tableYSpecify a table where
to write down
the parameter is stored.
Write to
Column
columnYSpecify a table column where
to write down
the parameter is stored.
Source
Mapping Column
mapping columnY

Specify the

The

table column where the routing rule triggers.

Specify the Source

Mapping Column

mapping column and Target

Mapping Column

mapping column fields

in case

if the resulting table is another one than the table where the request

triggers

is triggered.

Target
Mapping ColumnThe
mapping columnY

Specify the table column to put the request result.

How it works

It works in the following way:

The request result is recorded into the Write to

Table

table table record where the values in the Source

Mapping Column

mapping column and Target

Mapping Column

mapping column columns match.

It means that

The value in

the 

the Source

Mapping Column

mapping column column of the Write to

Table

table should match the value of the Target

Mapping Column

mapping column of the Write to

Table

table.

If the values do not match,

then the

an error is thrown

and registered in

. It also appears in the Bot Request History table.

Bot request history


In there, the bot requests history to To check out the history of the requests to the third-party services is stored.To check out the history, please complete the following steps below.:

  1. Navigate to Bots API → Bot Request History.
  2. Click on the record you need to inspect.read.

Bot Request History form fields

FieldDescription
Record
ID
The record ID on which the request
has been
was generated.
State

The request state. Available options:

  • Sent
-
  • the request
was
  • is sent and processed successfully; third-party service did not throw any exceptions.
  • Error
-
  • the request
was
  • is sent and processed with errors displayed in the Response field.
  • Sending
-
  • the request
was
  • is sent and is waiting for the answer from the API provider.
Info

If no answer is received in 10 minutes,

then

the request state is changed to Error automatically.


Bot Routing Rule
Bot
The bot routing rule on which the request has been generated.
URLThe URL of the request specified.
Method
Method
The method of the request specified.
Headers
Headers
The headers of the request specified.
Body
Body
The body of the request specified.
Response
This field contains

The request response

useful

. It is used for debug or troubleshooting.

In there, you

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.

Implementation example

Consider an user case: you need to implement direct notification via messengers.

Input data you have:

Employee nameJohn DoeEmployee's messenger ID#R11F0G2SDEmployee's sys_id on the SimpleOne instance 160707678680781750

First step

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:

Code Block
languagejs
themeEclipse
titleBot Method
linenumberstrue
{
  "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.

Second step

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):

Code Block
languagejs
themeEclipse
titleRouting Parameters
linenumberstrue
{
  "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.

Note

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:

  • single backslashes are replaced with slashes
  • double quotes are escaped with a backslash
Code Block
languageperl
themeEclipse
titleRegular Expression
return `Comment: ${current.additional_comments}`
  .replace(/(?<!\\)(?:((\\\\)*)\\)(?![\\/])/g, '\/')
  .replace(/"/g, '\\"')

Third step

Create a routing parameter. For this, create a record in the Routing Parameter (sys_routing_parameter) table. Fill in the field as described below:

#R11F0G2SD
FieldDescriptionValue
Bot methodReference to the method using current routing parameter to send a message to employee.send.message.to.employee
Column valueThis value is searched for match by the bot routing rule. In our example, it's employee's ID on SimpleOne instance. 160707678680781750
Parameter valueThis 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.

a request was created or sent.


Table of Contents
absoluteUrltrue
classfixedPosition