Combine free text + buttons

Hello Team! I was wondering if there’s a way to combine free text with buttons. The scenario would be something like Yes-No question (so buttons would be provided) but also if the user decides to enter: “yes|sure|go ahead” the NLU should be able to pick that up as well.

Best.

When there are buttons, the user can still type whatever they want - Unless you have blocked this in your application of course

Hello @ChrisRahme , thanks for answering back. That makes sense. What would be the best way of implementing such behavior? What I mean is, let’s say the user answers “Yes” or “Sure” and I want to identify that this specific response comes from a certain flow in order to distinguish this “Yes” intent from another one. Should I use stories for this?

The only ways to distinguish them are to see if the text came as a payload (e.g. /affirm) or as text (e.g. yes), or using a separate intent for the buttons (e.g. button_affirm)

Mhmm, I’m not sure I followed. Would you mind providing a snippet of code?

If the user clicked on the button, it will send the text /affirm, assuming you followed the method shown here, contrarily to if the user wrote the answer themselves, in which case the text will be what the user typed.

In a custom action, you can get this with tracker.latest_message['text'].


Using this method again, create a button_affirm intent that you will solely use for buttons, so that when you encounter it, you know that the button has been pressed.

In a custom action, you can get this with tracker.latest_message['intent'].

Sorry to bother you one more time, but I’m still hesitant.

Supporting the interaction by using the payload (this is when the user clicks on the buttons) I know how to do it. However, when the user enters text (let’s say “Yes”), I guess I would previously need to mark somewhere that I’m waiting for a yes/no answer so the intent can be triggered conditionally from the NLU.

Isn’t that the case? Otherwise the answer of the user might get confused with a different intent.

You can build stories for when it’s the case and when it’s not, or you can handle it all in a custom action.