简体   繁体   English

如何从 HTML UI 发送自适应卡(使用 store.dispatch):microsoft/BotFramework-WebChat

[英]how to send Adaptive Card from HTML UI (using store.dispatch): microsoft/BotFramework-WebChat

I am trying to figure out how to send Adaptive Card from HTML UI.我想弄清楚如何从 HTML UI 发送自适应卡。

I can send message by a button click from UI (outside chat component).我可以通过从 UI(外部聊天组件)单击按钮来发送消息。

 store.dispatch({ type: 'WEB_CHAT/SEND_MESSAGE', payload: { text: 'Hello' } });

My requirement is to send adaptive card(button from HTML UI): like below我的要求是发送自适应卡(来自 HTML UI 的按钮):如下所示

 store.dispatch({ type: 'WEB_CHAT/SEND_MESSAGE', payload: { attchments: card.attachments } });

Looks like below event can be useful, but this seems to be for file attachment not for adaptive cards.看起来下面的事件可能很有用,但这似乎是用于文件附件而不是用于自适应卡。

 store.dispatch({ type: 'DIRECT_LINE/POST_ACTIVITY', meta: { method: 'customizedButton' }, payload: { activity: { attchments: card.attachments, channelData: { attachmentSizes: card.attachments } } } });

It will be great if there is way to send activity(with attachments and text), so that adaptive cards can be send to receiver and sender can see in send messages.如果有办法发送活动(带有附件和文本),那就太好了,这样自适应卡片就可以发送给接收者,并且发送者可以在发送消息中看到。 For example: using below code I can insert message, but this message is not sent to receiver.例如:使用下面的代码我可以插入消息,但该消息不会发送给接收者。

 store.dispatch({ type: 'DIRECT_LINE/INCOMING_ACTIVITY', payload: { activity: { type: 'message', timestamp: new Date().toString(), .... channelData: { clientActivityID: Math.random().toString(), clientTimestamp: '2020-10-31T10:20:30.074Z' } } } });

store.dispatch({ type: 'DIRECT_LINE/POST_ACTIVITY', meta: { method: 'keyboard' }, payload: { activity: { type: 'message', 'tag': 'value' } } });

In middleware we are using tag to detect value.在中间件中,我们使用标签来检测值。

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

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