How to access state variables set by Voice Agent from Watson Assistant?

135 Views Asked by At

As per the this document (https://cloud.ibm.com/docs/services/voice-agent?topic=voice-agent-api-reference#state-variables-iva) Voice Agent sets some state variables for Watson Assistant.

I want to access the caller number (vgwSIPFromURI) and pass it on to my cloud function as a parameter.

How can I do this?

Here is a simplified version of my code in the JSON editor:

{
  "output": {
    "text": {
      "values": [
        "<? $myResult ?>"
      ],
      "selection_policy": "sequential"
    }
  },
  "actions": [
    {
      "name": "/path/to/my/cloud-function",
      "type": "server",
      "parameters": {
        "name"  : "$name"
      },
      "credentials": "$myCredentials",
      "result_variable": "$myResult"
    }
  ]
}
1

There are 1 best solutions below

0
On BEST ANSWER

They're accessible as variables within Watson Assistant, so you can literally prepend a $ to the items shown on that page.

I just tested this by adding $vgwSIPFromURI to a dialog node on my Voice Agent enabled bot, and when I triggered that node over the phone it read the value out loud. You can just use $vgwSIPFromURI within your JSON (i.e. where you have $name currently) and the cloud function should receive the string as expected.