Skip to main content

Other Asserters

HTTP/JSON Endpoint, Email and SMS Asserters.

Chatbot HTTP/JSON Endpoint Asserter

Imagine you want to verify the content of shopping basket within the conversation flow test of an e-commerce chatbot. Botium can be instructed to call a HTTP/JSON API and assert the response within a conversation.

This Asserter takes Multiple Parameters:

  1. Base URI: This is mandatory (HTTP GET).
  2. HTTP Response Body - Expected Value: (Optional) - This is the expected output. If specified, Botium will compare the actual response from the URL call to this expected output. If not provided, Botium will only verify that the HTTP response code indicates success (2xx).
  3. JSONPath Expression: (Optional) - If not provided, the whole response is used for assertion.



Tip: If Scripting Memory is enabled, the scripting variables can be used to dynamically build up those parameters.

Example Botium Script

  • Asserting for HTTP response code
    #bot
    HTTP https://run.mocky.io/v3/9b72d65a-753f-47c8-91f7-9901dfe5ed64
  • Asserting for full HTTP response
    #bot
    HTTP https://run.mocky.io/v3/9b72d65a-753f-47c8-91f7-9901dfe5ed64 
    | 
    { 
      "orderNumber": 1234533, 
      "status": "OK" 
    }
    
  • Asserting for parts of the HTTP response
    #bot
    HTTP https://run.mocky.io/v3/9b72d65a-753f-47c8-91f7-9901dfe5ed64 
    | 
    1234533 
    | 
    $.orderNumber
    
    HTTP https://run.mocky.io/v3/9b72d65a-753f-47c8-91f7-9901dfe5ed64 
    | 
    OK 
    | 
    $.status
    
  • Asserting for plain text HTTP response
    #bot
    HTTP https://run.mocky.io/v3/fe8362a8-c50f-4dc3-af53-b936d81b8a0a | OK
  • Base URI:The base URI for all the HTTP calls can be given in the global args for the asserter.

    {
      "botium": {
        "Capabilities": {
          ... 
          "ASSERTERS": [
            {
              "ref": "HTTP",
              "src": "botium-asserter-http",
              "args": {
                "baseUri": "https://run.mocky.io/v3"
              }
            }
          ]
        }
      }
    }

    The BaseURI is prefixed to all HTTP calls (if they are not absolute URLs):

    #bot
    HTTP /fe8362a8-c50f-4dc3-af53-b936d81b8a0a | OK

    This is useful for having several environment-specific configurations for this asserter, each one pointing to another server, for example:

    * [https://my-api-dev](https://my-api-dev) in the DEV environment
    * [https://my-api-sit](https://my-api-sit) in the SIT environment
    
    Note: In Botium, you have to register the HTTP Asserter multiple times and add them as Registered Component to the Test Projects for each environment.

Email Inbox Asserter

This asserter checks the email inbox for any received messages since the test conversation started. If parameters are given, it checks if the email sender, subject or body matches.

Configure the Email Inbox Component

  1. Navigation: On the left pane, navigate to Botium Tools & Settings > Settings > Components.
  2. Email Inbox Asserter: Ensure that you are on the TEST EXECUTION COMPONENTS tab, and then filter by “email” to find and open the Email Inbox Asserter.
  3. Configure Inbox: Scroll down to the field Component Configuration (JSON-formatted). Here you will see a sample configuration which includes three separate email inboxes. To configure your inbox simply replace the configuration with the config of your email inbox.
    Tip: Take note of the 'Component Ref Code' which is highlighted in the image below. This will be used when adding assertions to a test case - CHECKINBOX
    {
      "mailbox1": {
        "user": "imap-user-name@gmail.com",
        "password": "imap-password",
        "host": "imap.gmail.com",
        "port": 993,
        "tls": true
      },



  4. Optional: You can also add a filter for Sender in your email inbox configuration to assert only for an emails received by a specific address.



  5. Add the Asserter to a Test Case: Once the component is configured, you can add the assertion to a Bot Step in any Test Case.

    Navigate to Botium Tools & Settings > Test Sets > Your Test Set > Test Cases > Your Test Case. Then, add or edit the Bot Step you want to assert on.

    • Enter the Mailbox Name: This is the identifier used in the JSON configuration. In the example above "mailbox1" is used.
    • Enter the Text to Assert: This text will be searched in the sender, subject and body of the email.



Example Botium Script (for copy/paste)
My Convo

#me
hello

#bot
hello
CHECKINBOX mailbox1|text of the welcome email
Note: The mailbox parameters are handed over 1:1 to the node-imap library for connecting to the IMAP server (https://github.com/mscdex/node-imap)

SMS Inbox Asserter

Imagine you want to check the SMS Inbox of a caller for a received SMS since the test conversation started. This asserter checks if the SMS body matches. To setup a SMS Asserter, follow the steps below.
Note: Currently the SMS Asserter only supports Twilio as an SMS provider.

Configure SMS Component:

  1. Navigation: On the left pane, navigate to Botium Tools & Settings > Settings > Components.
  2. SMS Inbox Asserter: Ensure that you are on the TEST EXECUTION COMPONENTS tab, and then filter by “SMS” to find the SMS Inbox Asserter . Click into it to open the configuration.



  3. Configure Inbox: Scroll down to the field Component Configuration (JSON-formatted). Here you will see a predefined SMS Inbox called DEFAULT



    Tip: You can add multiple SMS inboxes if required. The Twilio Account SID and Twilio Auth Token shown is an example. You can find these details on your Twilio Dashboard.
  4. Optional: You can also add a filter for Sender in your SMS Inbox configuration to only assert for an SMS that is received by a certain number:



Was this article helpful?

0 out of 0 found this helpful