猿问

如何在 OpenUrl 卡操作中回复消息?

我正在发送带有 openURL 的 cardAction,用户应该单击该按钮,按照所述 URL 中的说明进行操作,然后报告数据。我希望在用户单击按钮时(也就是打开 URL 时)显示一条消息。


根据我的测试,我只能选择 ImBack 或 OpenUrl。有没有办法在一个 CardAction 中同时完成这两项操作?


var card = new SigninCard()

{

    Buttons = new List<CardAction>()

    {

        new CardAction()

        {

            Title = "Open a URL",

            Type = ActionTypes.OpenUrl,

            Value = this.myURL,   

            DisplayText = "I want to show text when I open myURL but this text doesn't show",

        },

        new CardAction()

        {

            Title = "Message Back",

            Type = ActionTypes.ImBack,

            Value = "MessageBackButtonClicked",

        },

    },

};


aluckdog
浏览 119回答 1
1回答

慕沐林林

不幸的是,每个渠道都负责处理用户操作,并且大多数渠道不会在用户单击链接时通知您。但是,在 Web 聊天中,您可以使用卡片操作中间件在用户单击打开 URL 操作时调度反向通道事件。请注意,这仅适用于网络聊天,不适用于任何其他渠道。Bot 框架网络聊天 v4const cardActionMiddleware = ({ dispatch }) => next => action => {&nbsp; const { cardAction: { type, value } } = action;&nbsp; if (type === 'openUrl') {&nbsp; &nbsp; dispatch({&nbsp; &nbsp; &nbsp; type: 'WEB_CHAT/SEND_EVENT',&nbsp; &nbsp; &nbsp; payload: {&nbsp; &nbsp; &nbsp; &nbsp; name: 'webchat/urlClickedEvent',&nbsp; &nbsp; &nbsp; &nbsp; value: `Navigating to ${value}`&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; });&nbsp; }&nbsp; return next(action);}window.WebChat.renderWebChat({&nbsp; cardActionMiddleware,&nbsp; directLine,}, document.getElementById('webchat'));希望这可以帮助!
随时随地看视频慕课网APP
我要回答