Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing variables into Watson Dialog

In many situations, it may be helpful to pass known information (e.g. the user's name to present a personalized greeting) into a new Watson Dialog conversation so to avoid asking the user redundant or unnecessary questions. In looking at the API documentation, I don't see a way to do that. Is there a best practice method for passing variables into a Watson Dialog conversation?

like image 645
Jim Hoskins Avatar asked Oct 19 '22 23:10

Jim Hoskins


1 Answers

In the Dialog service a variable is part of a profile that you create to store information that users provide during conversations.

The following code shows an example of a profile variable that saves the user's name.

<variables>
    <var_folder name="username">
        <var name="username" type="TEXT" description="The user's name."></var>
    </var_folder>
</variables>

In your scenario you will set this variable by calling:

PUT /v1/dialogs/{dialog_id}/profile

with:

{
  "client_id": 4435,
  "name_values": [
    {
      "name": "username",
      "value": "Bruce Wayne"
    }
  ]
}

Don't forget to replace {dialog_id} and {client_id}.


We have an API Explorer that let you try-out the APIs: Dialog API Explorer.
You can also read more about this in this tutorial.

like image 188
German Attanasio Avatar answered Oct 22 '22 21:10

German Attanasio