Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bot Framework Event for Postbacks?

My question:

I have an adaptive card with a postback button whose value is say "thisIsMyPostback". Now, I want to act on this postback as one would.

The problem is that this postback can also be typed out to reach the same result. In other words, clicking the button and also just messaging my bot "thisIsMyPostback" straight up result in the same thing.

Is there a way to separate a postback message from a 'message_received'? That way a user messaging "thisIsMyPostback" straight up would not result in the same thing as clicking the button.

Thanks!

like image 554
Fabien Bessez Avatar asked Feb 16 '26 05:02

Fabien Bessez


2 Answers

The Adaptive Cards readme on the BotFramework WebChat GitHub repo GitHub repo states:

The data property of the action may be a string or it may be an object. A string is passed back to your bot as a Bot Builder SDK imBack activity, and an object is passed as a postBack activity. Activities with imBack appear in the chat stream as a user-entered reply. The postBack activities are not displayed.

"actions": [
          {
            "type": "Action.Submit",
            "title": "Next",
            "data": { "postBack": "thisIsMyPostback" }
          }
        ]

If the value of the Activity doesn't have an object, then the user did not click the button.

like image 162
Eric Dahlvang Avatar answered Feb 17 '26 18:02

Eric Dahlvang


Is there a way to separate a postback message from a 'message_received'? That way a user messaging "thisIsMyPostback" straight up would not result in the same thing as clicking the button.

No, it's not currently possible, because all messages, user or imBack/postBack, are of type "message" so there's no way to tell the difference unless you put some special text in your postBack and configure a triggerAction to recognize it.

For more information on using trigger actions, see: https://learn.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-global-handlers#trigger-a-help-dialog

like image 38
nwxdev Avatar answered Feb 17 '26 17:02

nwxdev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!