用于回发的 Bot 框架事件?

Bot Framework Event for Postbacks?

我的问题:

我有一张带有回发按钮的自适应卡,其值为 "thisIsMyPostback"。现在,我想像往常一样对这个回传采取行动。

问题是这个回发也可以打出来达到同样的结果。换句话说,单击按钮并直接向我的机器人 "thisIsMyPostback" 发送消息会产生相同的结果。

有没有办法将回发消息与 'message_received' 分开?这样一来,用户直接发送消息 "thisIsMyPostback" 不会产生与单击按钮相同的结果。

谢谢!

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.

不,目前不可能,因为所有消息,用户或 imBack/postBack,都是 "message" 类型,所以除非您在回发中放置一些特殊文本,否则无法区分它们配置一个 triggerAction 来识别它。

有关使用触发器操作的详细信息,请参阅: https://docs.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-global-handlers#trigger-a-help-dialog

BotFramework WebChat GitHub 存储库 GitHub repo 上的自适应卡片自述文件指出:

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" }
          }
        ]

如果 Activity 的值没有对象,那么用户没有点击按钮。