简体   繁体   English

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

[英]How to message back in an OpenUrl Card Action?

I am sending a cardAction with openURL where a user is supposed to click the button, follow instructions from said URL, and then report back the data. 我正在发送一个带有openURL的cardAction,其中用户应该单击按钮,按照所述URL的说明进行操作,然后报告数据。 I would like a message displayed when the user clicks on the button, which is also when the URL is opened. 用户点击该按钮,这也是URL打开时我想显示的消息。

From what I have tested, I can only either ImBack or OpenUrl. 根据我的测试,我只能使用ImBack或OpenUrl。 Is there a way to do both in one CardAction? 有没有办法在一个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",
        },
    },
};

Unfortunately, each channel is responsible for handling user actions and most channels do not notify you when a user clicks on a link. 不幸的是,每个通道都负责处理用户的操作,并且大多数通道在用户单击链接时不会通知您。 However, in Web Chat, you can use the card action middleware to dispatch a backchannel event when the user clicks on an open URL action. 但是,在Web聊天中,当用户单击打开的URL操作时,可以使用card action中间件来调度反向通道事件。 Note, this will only work with Web Chat and not any other channel. 请注意,这仅适用于网络聊天,不适用于任何其他渠道。

Bot Framework Web Chat v4 Bot Framework网络聊天v4

const cardActionMiddleware = ({ dispatch }) => next => action => {
  const { cardAction: { type, value } } = action;
  if (type === 'openUrl') {
    dispatch({
      type: 'WEB_CHAT/SEND_EVENT',
      payload: {
        name: 'webchat/urlClickedEvent',
        value: `Navigating to ${value}`
      }
    });
  }
  return next(action);
}

window.WebChat.renderWebChat({
  cardActionMiddleware,
  directLine,
}, document.getElementById('webchat'));

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM