Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Getting improper response from Virtual Agent bot integration API

Raghav Aggarwal
Giga Contributor

I am using the Virtual Agent bot integration API to add a bot to my application.
Whenever I send some random message (example - hii) to the API for the first time I get a valid response from the API i.e
find_real_file.png

But after this, if I send some random request to the API, I get `undefined` in the response

Expected- 
find_real_file.png

 

Currently - 
find_real_file.png

 

After the above `hii` request I am getting the following response - 
find_real_file.png

If I send the `hii` message again after this then I get the proper response.

Am I missing out on some configuration?

6 REPLIES 6

Rahul Kumar3
ServiceNow Employee
ServiceNow Employee

Hi @Raghav Aggarwal

Can you please share the VA API version and the complete request payload? 
Do you see any error messages in the logs? 

Hi @Rahul Kumar,

I am using version "3.1.0" of VA API.

Request payload looks like this-
find_real_file.png

No, I don't see any error message in the logs just getting the "undefined" response.

I did find something on this. I am getting the "undefined" response when the secondary bot is handing the conversation over to the primary bot but ideally, I should get a "takeControl" flag in the response.

Rahul Kumar3
ServiceNow Employee
ServiceNow Employee
@Raghav Aggarwal, Can you please try to hit the endpoint with the below payload from the postman and share the response? 

Endpoint: https://instance.service-now.com/api/sn_va_as_service/bot/integration
 
Header:- 
Content-Type: application/json
 
Payload :- 
{
"requestId": "dfs-4rfg-qwe23-dsds",
"action": "",
"enterpriseId": "ServiceNow",
"message":{
"text":"hii",
"typed": true,
"clientMessageId": "ABC-123"
},
"userId": "beth",
"emailId": "",
"timestamp": 1588824102,
"timezone": "America/New_York"
}

@Rahul Kumar 

This is the response I get first time I sent the request- 

{
  "requestId": "dfs-4rfg-qwe23-dsds",
  "message": {
    "text": "hii",
    "typed": true,
    "clientMessageId": "ABC-123"
  },
  "userId": "beth",
  "body": [
    {
      "uiType": "OutputText",
      "group": "DefaultText",
      "value": "I am sorry but I didn't understand your request.",
      "maskType": "NONE"
    },
    {
      "uiType": "OutputText",
      "group": "DefaultText",
      "value": "Please try giving me your request in a different way. I'm currently better at understanding short sentences.",
      "maskType": "NONE"
    },
    {
      "uiType": "TopicPickerControl",
      "group": "DefaultPicker",
      "nluTextEnabled": false,
      "promptMsg": "Hi there, please enter your request or make a selection of what I can help with. You can type help any time when you need help.",
      "label": "Show me everything",
      "options": [
        {
          "label": "Benefits Overview (Template)",
          "value": "b9b923af231400107e45ff5e17bf6553",
          "enabled": true
        },
        {
          "label": "Change in Benefits Inquiry (Template)",
          "value": "b81ad36c771101107e0df336ba5a9955",
          "enabled": true
        },
        {
          "label": "Check IT Ticket Status (Template)",
          "value": "55720b465bf0201024f11fc40a81c72d",
          "enabled": true
        },
        {
          "label": "Collaboration Applications (Template)",
          "value": "9c3b882253f02010a52bddeeff7b127f",
          "enabled": true
        },
        {
          "label": "Create Problem (Template)",
          "value": "c58656adc33020105ae0d2bf6d40dd41",
          "enabled": true
        },
        {
          "label": "Demo FLow",
          "value": "7c17c60e073c5110e2abf7108c1ed030",
          "enabled": true
        },
        {
          "label": "Email Issues (Template)",
          "value": "d324faa173702010b5c7e0dbc4f6a727",
          "enabled": true
        },
        {
          "label": "Enroll new Beneficiary​​ (Template)",
          "value": "20536df3c7c1011047b1d3de17c260ba",
          "enabled": true
        },
        {
          "label": "Live Agent Support.",
          "value": "ce2ee85053130010cf8cddeeff7b12bf",
          "enabled": true
        },
        {
          "label": "Reset Password (Template)",
          "value": "71919ecdc7d310100a9b5d83c7c26072",
          "enabled": true
        },
        {
          "label": "Start Virtual Machine CAI (Template)",
          "value": "6bf968a0ebd530103dedddde23522864",
          "enabled": true
        }
      ]
    }
  ],
  "score": 0
}


This is the response I get when I hit the same request multiple times (i.e - when I hit the API with the same request payload more than the value of "va.bot.to.bot.take.control_times")- 

find_real_file.png

I have set the value of "va.bot.to.bot.take.control_times" to 5. So, I get the "undefined" response in the 5th request when I hit the API with the same request payload.

find_real_file.png