3

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!

Eric Dahlvang
  • 8,252
  • 4
  • 29
  • 50

2 Answers2

1

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

nwxdev
  • 4,194
  • 3
  • 16
  • 22
1

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.

Eric Dahlvang
  • 8,252
  • 4
  • 29
  • 50