1

I am trying to use the new API version V2 for IBM Cloud Watson Assistant. Instead of sending a message for a workspace I need to send a message to an assistant. The context structure has global and skill-related sections now.

How would my app pass in values as context variables? Where in the structure would they need to be placed? I am using the Python SDK. I am interested in sending information as part of client dialog actions.

data_henrik
  • 16,724
  • 2
  • 28
  • 49

1 Answers1

2

Based on testing the Python SDK and the API V2 using a tool, I came to the following conclusion. Context is provided by the assistant if it is requested as part of the input options.

  "context": {
    "skills": {
      "main skill": {
        "user_defined": {
          "topic": "some chatbot talk", 
          "skip_user_input": true
        }
      }
    }, 
    "global": {
      "system": {
        "turn_count": 2
      }
    }
  }

To pass back values from my client / app to the assistant, I could use the context parameter. However, in contrast to the V1 API I needed to place the key / value pairs "down below" in the user_defined part:

context['skills']['main skill']['user_defined'].update({'mydateOUT':'2018-10-08'})

The above is a code snippet from this sample file for a client action. With that placement of my context variables everything works and I can implement client actions using the API Version 2.

data_henrik
  • 16,724
  • 2
  • 28
  • 49