Quick replies on watson conversation

422 views Asked by At

I'm using Watson conversation to do a messenger chatbot, and i need something like that

[![inserir a descrição da imagem aqui][1]][1]

https://i.stack.imgur.com/UTOyI.png

1

There are 1 answers

0
Juan Pablo Djeredjian On

Watson Conversation API does not have built-in UI tools to create the type of buttons or options that you want in a response.

In order to achieve that, what you need to do is send back a flag or variable in your context object inside Watson Conversation's response. Then, in your frontend code you can test that variable and programmatically decide if you need to display certain HTML components like buttons, options, etc.

Watson's response in your dialog node should look something like this:

{
  "context": {
    "showOptions": true
  },
  "output": {
    "text": {
      "values": [
        "Hi, do you want to hear a joke?"
      ],
      "selection_policy": "sequential"
    }
  }
}

And then in your code, you should check inside the context. If the showOptions property is true, then, while displaying the answer to the user's input you could add the options that you need (Yes, No, I don't know).

In your case, you don't even need to display the output.text.values[0], just the options.

Remember to turn the showOptions variable back to null in another dialog or your code will always display the options, even when you don't need to.