Use this block if your bot needs to post or fetch some data from any external web resource using HTTP protocol.

For example you can use this block to post collected user's data to your Google Sheet via IFTTT integration, or fetch some data from sheet via Read data from Google Sheets.

Block preferences



URL and method

You have to define URL of the external service. Also you can change the request method (GET/POST/PUT/DELETE). Any variables can be used in URL parameters, just enclose a variable name into $ with curly brackets (like on screenshot above).

Headers

On the Headers tab you can define a collection of headers of HTTP request. You also can use any variables but in common way with others blocks - just prepending the variable's name with $ symbol and without curly brackets.



Body

In case you send some data to the server via POST or PUT methods, you can define a body of HTTP request.



Please note that Aimylogic doesn't interpret the body of HTTP request somehow. It is only a text and you have to control the body's type via headers on your own.

You can use any variables in the body the same way as in the header's value or any other block in Aimylogic.

HTTP response and variables

If the response returns 200 OK result, the bot can extract any data from the response's body and store it to the named variables. On the Response tab you can define any number of such variables and the rules of its' extraction from the response.

Just add a new variable, type a name and provide a rule to extract the value of this variable from the HTTP response. Each rule is a Javascript expression and you can manipulate with $httpResponse variable that stores the entire response body.

If the service returns JSON you can obtain any field value via dot notation. Please take a look on the screenshot above to see an example.

Underscore

Aimylogic has underscrore.js library under the hood, thus you can use any functions of this Javascript library to manipulate $httpResponse to fetch the data.

Transition after request

Once a HTTP request was executed and all data fetched, bot jumps to the next screen that is connected to Success or Error connectors. If the response returned 200 OK status then Success branch is used. Otherwise an Error connection fires. In this case a variable named $httpStatus will be added to scenario with a error code.
Was this article helpful?
Thank you!