Search code examples
botium-box

Botium test chatbot button and text


Here is the part of the botium.json where i send my text request

 "SIMPLEREST_URL": "https://******************/messaging/api/widget/request",
      "SIMPLEREST_METHOD": "POST",
      "SIMPLEREST_HEADERS_TEMPLATE": {"Authorization" : "Basic *****************"},
      "SIMPLEREST_BODY_TEMPLATE": {
        "messageType" : "TEXT",
        "mediaType" : "DIGITAL",
          "messageContentType": "text/plain",
          "language": "en",
          "sessionID": "{{{context.sessionID}}}",
          "messageContent": "{{msg.messageText}}",
          "sequenceID": "{{{context.sequenceID}}}",
          "company": "**********",
          "connector": "demo_chatbot",
          "service": "demo_chatbot",
          "userContext": 
              {
                  "idTokenType": "LOGIN", 
                  "idToken": "******************"
              }
      },

if I want to test the button part, I need to change the messageType to USER_CHOICE, so my question is: How can I ensure that when I put the keyword BUTTON in my test file (.convo.txt) the messageType is changed to USER_CHOICE ?

Thanks


Solution

  • You may use a Botium request hook - some custom Javascript code to inject custom functionality into Botium. In your case it would look like this in your botium.json file:

    "SIMPLEREST_REQUEST_HOOK": "if (msg.buttons && msg.buttons.length > 0) { requestOptions.body.messageType = 'USER_CHOICE' }"