These logic hooks are used for managing HTTP requests and handling their responses. They are used for interacting with APIs, injecting responses into systems, and controlling data flow based on API interactions.
Make HTTP GET Request
This logic hook can be used to call a custom HTTP API endpoint. It can be used only as a User Step. This guide explains how to set up a logic hook in Botium to make an HTTP GET request to a specified URL.
Steps:
- On the left navigation pane, head to
Botium Tools & Settings > Test Sets > Your Test Set > Test Cases
- Click the + NEW button to add a new Convo, or select a previously created test case from the list.
- Add a new + USER STEP
- Click the Edit icon, or anywhere inside the step, and search the list
for the 'Make HTTP GET Request' logic hook.
-
Configure the Logic Hook:
-
URL to Call: Specify the URL to call. The URL can contain
scripting memory variables. For example:
https://my-custom-api/get-response/$msg($.messageText)
-
Optional Headers: You can add headers if you wish by
clicking the ADD NEW HTTP HEADER button. These are entered as
key/value pairs.
-
URL to Call: Specify the URL to call. The URL can contain
scripting memory variables. For example:
- Click the APPLY CHANGES button to complete the step entry.
Example Botium Script
#me
give me 2
#bot
2
HTTPGET https://jsonplaceholder.typicode.com/posts/$msg($.messageText)
HTTPGET https://jsonplaceholder.typicode.com/posts/$msg($.messageText) |
ARG-HEADERS-[{"name":"Someheaderkey","value":"someheadervalue"}]
Explanation:
-
makes an HTTP GET request to the URLHTTPGET https://jsonplaceholder.typicode.com/posts/$msg($.messageText)
https://jsonplaceholder.typicode.com/posts/2
, where2
is extracted from the chatbot's response using the$msg($.messageText)
function. - Headers can be added using the
ARG-HEADERS
parameter to include additional key/value pairs in the request.
Make HTTP POST Request
This logic hook can be used only as a User Step. This guide explains how to set up a logic hook in Botium to make an HTTP POST request to a specified URL.
Steps:
- On the left navigation pane, head to
Botium Tools & Settings > Test Sets > Your Test Set > Test Cases
- Click the + NEW button to add a new Convo, or select a previously created test case from the list.
- Add a new + USER STEP
- Click the Edit icon, or anywhere inside the step, and search the list
for the 'Make HTTP POST Request' logic hook.
-
Configure the Logic Hook:
- URL to Call: Specify the URL to call. Both the URL and the Request Body can contain scripting memory variables.
- Request Body: Specify the request body. You can leave this parameter empty to send an empty POST body.
-
Optional Headers: You can add headers if you wish by
clicking the ADD NEW HTTP HEADER button. These are entered as
key/value pairs.
- Click the APPLY CHANGES button to complete the step entry.
Example Botium Script
#begin
HTTPPOST https://jsonplaceholder.typicode.com/posts | { "username": "Joe", "userId": 1 }
#me
Hello!
HTTPPOST https://jsonplaceholder.typicode.com/posts |
{
"username": "Joe",
"userId": 1
} |
ARG-HEADERS-[{"name":"Someheaderkey","value":"someheadervalue"}]
Explanation:
-
makes an HTTP POST request to the URLHTTPPOST https://jsonplaceholder.typicode.com/posts | { "username": "Joe", "userId": 1 }
https://jsonplaceholder.typicode.com/posts
with a body containing{"username": "Joe", "userId": 1}
. - Headers can be added using the
ARG-HEADERS
parameter to include additional key/value pairs in the request.
Inject HTTP GET Response
This logic hook can be used to call a custom HTTP API and inject the response content into a User or Bot Message. It can be used as either a Bot or User Step.
Overview:This guide explains how to set up a logic hook in Botium to extract a chatbot's text response, send it to an API, and use the API response as the chatbot's reply.
In this example, the Scripting Memory Function
$msg
extracts the chatbot's text response from the message using
the JSON-Path expression $.messageText
. This extracted response is
sent to an API call. The API response's body field is then injected back into the
messageText
field, which will be used in the Botium pipeline as
the text response for assertions.
Steps:
- On the left navigation pane, head to
Botium Tools & Settings > Test Sets > Your Test Set > Test Cases
- Click the + NEW button to add a new Convo, or select a previously created test case from the list.
- Add a new + USER STEP or + BOT STEP
- Click the Edit icon, or anywhere inside the step, and search the list for
the 'Inject HTTP GET Response' logic hook.
-
Configure the logic hook:
-
URL to Call: Enter the URL for the HTTP GET request. For
example:
https://jsonplaceholder.typicode.com/posts/$msg($.messageText)
-
JSON-Path Extractor: Specify the JSON-Path expression to
extract the desired part of the response. For example:
$.body
-
Attribute to Set: Set the attribute in the message where the
extracted response will be injected. For
example:
messageText
-
URL to Call: Enter the URL for the HTTP GET request. For
example:
- Click the APPLY CHANGES button to complete the step entry.
Example Botium Script
#me
give me 2
#bot
SETFROMHTTPGET
https://jsonplaceholder.typicode.com/posts/$msg($.messageText)
| $.body
| messageText
SETFROMHTTPGET
https://jsonplaceholder.typicode.com/posts/$msg($.messageText)
| $.body
| messageText
| ARG-HEADERS-[{"name":"Someheaderkey","value":"someheadervalue"}]
Explanation:
-
SETFROMHTTPGET
initiates the HTTP GET request. - The URL
https://jsonplaceholder.typicode.com/posts/$msg($.messageText)
uses the$msg($.messageText)
function to insert the chatbot’s text response. -
| $.body | messageText
indicates that the API response's body will be injected back into themessageText
field. -
ARG-HEADERS
is used to add custom headers to the API request.
Inject HTTP POST Response
This logic hook can be used to call a custom HTTP API and inject the response content into a User or Bot Message. It can be used as either a Bot or User Step.
This guide explains how to set up a logic hook in Botium to make an HTTP POST request, extract the response content, and use it as the chatbot's reply.
Steps:
- On the left navigation pane, head to
Botium Tools & Settings > Test Sets > Your Test Set > Test Cases
- Click the + NEW button to add a new Convo, or select a previously created test case from the list.
- Add a new + USER STEP or + BOT STEP
- Click the Edit icon, or anywhere inside the step, and search the list
for the 'Inject HTTP POST Response' logic hook.
-
Configure the Logic Hook:
-
URL to call: Specify the URL to call.Tip: Both the URL and the Request Body can contain scripting memory variables. For example;
- URL: https://my-custom-api/post-response/$msg($.messageText)
- Request Body: { "title": "$msg($.messageText)" }
- Request Body: Set the body of the request. You can leave this parameter empty to send an empty POST body.
- JSON-Path Extractor: Add your JSON extractor here to extract the data item from the HTTP POST JSON response.
- Attribute to Set: Specify the Botium Core field to set.
-
Optional Headers: If you wish to add new headers, click
the ADD NEW HTTP HEADER button. These are added as
key/value pairs.
-
URL to call: Specify the URL to call.
- Click the APPLY CHANGES button to complete the step entry.
Example Botium Script
https://jsonplaceholder.typicode.com/posts
. The API response's
body field is then injected back into the messageText
field, which
will be used in the Botium pipeline as the text response for
assertions.#me
give me something
#bot
SETFROMHTTPPOST
https://jsonplaceholder.typicode.com/posts
| { "title": "$msg($.messageText)", "body": "$msg($.messageText)", "userId": 1 }
| $.body
| messageText
You said: give me something
SETFROMHTTPPOST
https://jsonplaceholder.typicode.com/posts
| { "title": "$msg($.messageText)", "body": "$msg($.messageText)", "userId": 1 }
| $.body
| messageText
| ARG-HEADERS-[{"name":"Someheaderkey","value":"someheadervalue"}]
Explanation:
-
SETFROMHTTPPOST
initiates the HTTP POST request. - The URL
https://jsonplaceholder.typicode.com/posts
uses the$msg($.messageText)
function to insert the chatbot’s text response into the request body. -
| $.body | messageText
indicates that the API response's body will be injected back into themessageText
field. -
ARG-HEADERS
is used to add custom headers to the API request.
Inject HTTP GET Response into Parameter Store
This logic hook can be used to call a custom HTTP API and inject the response content into the parameter store. This allows you to create a new variable or overwrite an existing one. It can be used as either a Bot or User Step.
This guide explains how to set up a logic hook in Botium to call an HTTP GET API, extract the response content, and store it in the parameter store.
Steps:
- On the left navigation pane, head to
Botium Tools & Settings > Test Sets > Your Test Set > Test Cases
- Click the + NEW button to add a new Convo, or select a previously created test case from the list.
- Add a new + USER STEP or + BOT STEP
- Click the Edit icon, or anywhere inside the step, and search the list
for the 'Inject HTTP GET Response into Parameter Store' logic
hook.
-
Configure the Logic Hook:
-
URL to Call: Specify the URL for the HTTP GET request.
The URL can contain scripting memory variables. For example:
https://jsonplaceholder.typicode.com/posts/$msg($.messageText)
-
JSON-Path Extractor: Specify the JSON-Path expression to
extract the desired part of the response. For example:
$.title
-
Parameter Store Variable: Set the parameter name in the
parameter store where the extracted response will be injected.
For example:
apiResponse
-
Optional Headers: You can add headers if you wish by
clicking the ADD NEW HTTP HEADER button. These are
entered as key/value pairs.
-
URL to Call: Specify the URL for the HTTP GET request.
The URL can contain scripting memory variables. For example:
- Click the APPLY CHANGES button to complete the step entry.
Example Botium Script:
https://jsonplaceholder.typicode.com/posts/2
. The API
response's title field is then injected into the parameter store as the variable
apiResponse
.
#me
give me 2
#bot
2
SETPARAMETERSTOREFROMHTTPGET https://jsonplaceholder.typicode.com/posts/$msg($.messageText) | $.title | apiResponse
#me
$apiResponse
#bot
You said: qui est esse
SETPARAMETERSTOREFROMHTTPGET
https://jsonplaceholder.typicode.com/posts/$msg($.messageText)
$.title
apiResponse
ARG-HEADERS-[{"name":"Someheaderkey","value":"someheadervalue"}]
Explanation:
-
SETPARAMETERSTOREFROMHTTPGET
initiates the HTTP GET request. - The URL
https://jsonplaceholder.typicode.com/posts/$msg($.messageText)
uses the$msg($.messageText)
function to insert the chatbot’s text response. -
$.title | apiResponse
indicates that the title field from the API response will be extracted and stored as the variableapiResponse
in the parameter store. -
ARG-HEADERS
is used to add custom headers to the API request.
Inject HTTP POST Response into Parameter Store
This logic hook can be used to call a custom HTTP API and inject the response content into the parameter store. This allows you to create a new variable or overwrite an existing one. It can be used as either a Bot or User Step.
This guide explains how to set up a logic hook in Botium to call an HTTP POST API, extract the response content, and store it in the parameter store.
Steps:
- On the left navigation pane, head to
Botium Tools & Settings > Test Sets > Your Test Set > Test Cases
- Click the + NEW button to add a new Convo, or select a previously created test case from the list.
- Add a new + USER STEP or + BOT STEP
- Click the Edit icon, or anywhere inside the step, and search the list
for the 'Inject HTTP POST Response into Parameter Store' logic
hook.
-
Configure the Logic Hook:
-
URL to call: Specify the URL to call.Tip: Both the URL and the Request Body can contain scripting memory variables. For example;
- URL: https://my-custom-api/post-response/$msg($.messageText)
- Request Body: { "title": "$msg($.messageText)" }
- Request Body: Set the body of the request. You can leave this parameter empty to send an empty POST body.
-
JSON-Path Extractor: Add your JSON extractor here to
extract the data item from the HTTP POST JSON response. For
example:
$.username
-
Parameter Name: Set the parameter name in the parameter
store where the extracted response will be injected. For
example:
name
-
Optional Headers: You can add headers if you wish by
clicking the ADD NEW HTTP HEADER button. These are entered as
key/value pairs.
-
URL to call: Specify the URL to call.
- Click the APPLY CHANGES button to complete the step entry.
Example Botium Script:
name
in the parameter
store.#begin
SETPARAMETERSTOREFROMHTTPPOST
https://jsonplaceholder.typicode.com/posts
{ "username": "Joe", "userId": 1 }
$.username
name
#me
Hello $name!
#bot
You said: Hello Joe!
SETPARAMETERSTOREFROMHTTPPOST
https://jsonplaceholder.typicode.com/posts
{ "username": "Joe", "userId": 1 }
$.username
name
ARG-HEADERS-[{"name":"Someheaderkey","value":"someheadervalue"}]
Explanation:
-
SETPARAMETERSTOREFROMHTTPPOST
initiates the HTTP POST request. - The URL
https://jsonplaceholder.typicode.com/posts
uses the$msg($.messageText)
function to insert the chatbot’s text response into the request body. -
$.username | name
indicates that the username field from the API response will be extracted and stored as the variablename
in the parameter store. -
ARG-HEADERS
is used to add custom headers to the API request.