Using buttons with custom connectors

Hi, does anyone know how to send message with clicked button to chatbot via POST http://localhost:5000/webhooks/rest/webhook so that intent will be determined on the basis of picked button?

Example:

User can pick one of two buttons:

  • yes

  • no

Where should I insert data about which button was picked in this json?

{
   "sender": "123",
   "message": "" 
}

I found a solution. You can send json with intent name preceeded with / like this:

{
   "sender": "123",
   "message": "/affirm" 
}

or just pass it anywhere in json

{
   "sender": "123",
   "message": "",
   "button": "/affirm"
}

and then extract it in your custom RestInput receive method

button = self._extract_button(request)
if button is not None:
    text = button

and send it as a text ‘inside’ chatbot

await on_new_message(
       UserMessage(text, collector, sender_id, input_channel=input_channel, metadata=metadata)
)