How to create and configure Slots

icon picker
External Request slot (Sending Requests to APIs from script)

Purpose and general information

The
@External Request
⁠
@Slot
⁠
is designed to integrate the
@Agent
⁠
with external IT systems via the HTTP protocol (REST API or GraphQL, for example). When processing this
@Slot
⁠
in the
@Script
⁠
, an HTTP request to the API of the external system is executed, as well as a response to this request is received and processed.
⁠
image.png
⁠
⁠

Slot creation and settings

Slot attributes

The
@External Request
⁠
@Slot
⁠
does not contain settings for the HTTP request it sends; it contains an
@External Request
⁠
from
@Company Resources
⁠
, and the
@External Request
⁠
contains all the necessary settings for sending the request and processing the response.
⁠
image.png
⁠
⁠
Name — the name of the
@Slot
⁠
, which will be displayed in the Scenario Tree. The maximum length of a field value is 40 characters.
Request —
@External Request
⁠
from
@Company Resources
⁠
. Incremental case-insensitive search for a query in the list works.
SHOW REQUEST IN A NEW TAB button — by clicking the button, the external request selected in the field opens in the next browser tab.

Delay in sending request

The user can configure an
@External Request
⁠
to delay the sending of an
@External Request
⁠
— wait some time before the request is sent. To do this, you need to specify a special header er-delay in the request headers in the Headers section with the value equal to delay for sending an external request in seconds.
Requirements for the er-delay value:
integers - from 0 to 60
numbers greater than 60 are treated as 60
fractional numbers, negative numbers and non-numbers are treated as 0
⁠
image.png
⁠
⁠
Examples:
er-delay header is missing corresponds to a wait of 0 seconds
er-delay: 10 corresponds to a wait of 10 seconds
er-delay: 0 corresponds to a wait of 0 seconds
er-delay: 100500 corresponds to a wait of 60 seconds
er-delay: -100500 corresponds to a wait of 0 seconds
er-delay: non-integer-value corresponds to a wait of 0 seconds

External requests

An
@External Request
⁠
is a
@Company Resources
⁠
object, that is, it is accessible from all
@Agent
⁠
s of a given
@Company
⁠
. You can add, change, view or delete a request at .

Slot operation

⁠
@External Request
⁠
@Slot
⁠
execution process:
Definition of an
@External Request
⁠
to be executed;
Assembly of the final URL of an
@External Request
⁠
;
Collection of request headers;
Assembly of the request body;
Sending a request;
Receiving a response and recording
@Context Variable
⁠
s.
Timeout for waiting for a response to an
@External Request
⁠
— 30 seconds
If the size of the body received in response to an
@External Request
⁠
is larger than 5 KB, but less than 100 KB, {”error”:”received body is larger than 5kb, you can parse it in External Request settings, but it will not be copied to raw_response”} is written in
@raw_response
⁠
;
If the size of the body received in response to an
@External Request
⁠
is larger than 100 KB then the body is replaced with an empty one.
The following is written in
@raw_response
⁠
: ​{”success”:false,”error”:”received body is too big, max 100kb allowed”}.
If the size of the body received in response to an
@External Request
⁠
is not larger than 100 KB then an attempt will be made to parse the response in accordance with the parsing settings in the Response tab ​
image.png
⁠
⁠
If, when trying to parse, it was possible to find a value in the given path, the corresponding
@Context Variable
⁠
will be created\updated
If, when trying to parse, it was not possible to find a value in the specified path, the corresponding
@Context Variable
⁠
is not created\updated
An attempt to parse a response to a request will be made for any request response code if the parsing settings are specified in the Response tab
When processing a response to a request, the request response code is written to the
@response_status_code
⁠
variable:
If it is impossible to complete the request, code 400 will be written
When the timeout of 30 seconds expires, code 408 will be written
If there is no response from the server, code 499 will be recorded
Based on the results of the execution of the
@External Request
⁠
, the
@request_success
⁠
variable is created, which records the result of the request execution — success (True) or failure (False):
If it is impossible to complete the request or there is no response from the server, False will be written to
@request_success
⁠
If the response code is >=400, False will be written to
@request_success
⁠
If the response code is 200, but there is no (including an empty {} BODY) or invalid body for this type of expected response, if the response is expected to be parsed (there are entries in the Response tab), False will be written to
@request_success
⁠
In other cases, True will be written to
@request_success
⁠
— the request was successfully completed
Based on the result of executing an
@External Request
⁠
, the
@raw_response
⁠
variable is created in the format {”result of request execution”,”response body”}, example: {”success”:true,”temperature”:”-7.3”,”feels_like”:”-14.3 ”}.
The variable consists of two parts:
The first part contains the result of the request "success":true or "success":false, which is a duplicate of the
@raw_response
⁠
variable (the result depends on the conditions described in paragraph 5)
The second part contains the response body:
If successful, the response body contains the parsing result specified by the settings on the Response tab: ​
image.png
⁠
⁠
If unsuccessful, the response body contains the text of the error received from the external system ​
image.png
⁠
⁠
if the request to the external system could not be sent, then the error value is written to
@raw_response
⁠
⁠
if a request to an external system was successfully sent, but no response was received, then the value no response is written to
@raw_response
⁠
⁠
When receiving .xml from an external system, the response is written as a line.
When receiving an empty {} BODY from an external system, an empty string is written to the response body.

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.