5

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?

German Attanasio
  • 22,217
  • 7
  • 47
  • 63
Jim Hoskins
  • 270
  • 1
  • 9

2 Answers2

4

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.

German Attanasio
  • 22,217
  • 7
  • 47
  • 63
  • Sorry German but I am new... I don't see where I can accept the answer which I very much wan to do... please advise. – Jim Hoskins Oct 26 '15 at 01:10
  • As the author of the question, you'll see an outline of a checkmark on the left side of each answer. It'll be right below the up and down vote arrows. Click the checkmark next to the post that best answers your question to accept that answer as the best one. Click the tick (check mark) on left under the vote arrows. – German Attanasio Oct 26 '15 at 03:34
-1

It should also be noted that if you leave the client_id out then one is allocated for you. You can then pass this in to the start conversation call to make sure the that the profile is picked up. I found this useful where I have welcome messages which I want to imbed profile variables in to e.g. "Hello "