MS Teams 消息扩展 - 使用另一个任务模块响应 onSubmitAction [英] MS Teams Message Extension - Respond to onSubmitAction with another task module
问题描述
我正在 Microsoft 团队中创建消息扩展,但在从 CommandBar 链接任务模块时遇到了一些问题(这是重要的部分)
I am creating a message extension in Microsoft teams and I am running into some issues with chaining task modules from the CommandBar (This is the important part)
我有 2 个任务模块,A 和 B.
I have 2 task modules, A and B.
目标:从 CommandBar 运行一个命令,该命令将响应任务模块 A.在提交任务模块时,消息扩展应响应任务模块 B.
The Goal: Run a command from the CommandBar that will respond with task module A. On submitting the task module the message extension should respond task module B.
问题:我无法弄清楚如何从 onSubmitAction 函数内部(在实现 IMessagingExtensionMiddlewareProcessor 的消息扩展中使用任务模块进行响应.
The issue: I can't work out how to respond with a task module from inside the onSubmitAction function (on the message extension implementing IMessagingExtensionMiddlewareProcessor.
这是我的代码的简化版本:
Here is a cut down version of my code:
export default class HelpDeskMessageExtension implements IMessagingExtensionMiddlewareProcessor {
public async onFetchTask(): Promise<MessagingExtensionResult | TaskModuleContinueResponse | TaskModuleMessageResponse> {
return Promise.resolve<TaskModuleContinueResponse>({
type: "continue",
value: {
url: `${process.env.HostName}/helpdesk.html`,
width: 500,
height: 500,
},
});
}
public async onSubmitAction(context: TurnContext): Promise<any> {
//TODO: If this submit came from task module A, respond with Task module B
// If this came from task module B, respond with a success card
const heroCard = CardFactory.heroCard('<span style="color: green">Message successfully sent</span>',);
await context.sendActivity({ attachments: [heroCard] });
}
}
注意:这在使用撰写框中的消息扩展时工作正常.问题是从 CommandBar
Note: This works fine when using the message extension from the compose box. The issue is running this extension from the CommandBar
任何帮助将不胜感激.
推荐答案
发布答案以获得更好的知识从@Ghojzilla 评论中复制.我正在使用一个名为 botbuilder-teams-messagingextensions 的 npm 包,我认为它是 MS bot 框架的一部分.该包将来自提交操作的任何响应对象包装在composeExtension"文件中.属性,因此我无法将其包装在任务中.
Posting the Answer for better knowledge Copying from @Ghojzilla comments. I was using a npm package called botbuilder-teams-messagingextensions which I thought was part of MS bot framework. The package was wrapping any response object from the submit action in a "composeExtension" property so I couldn't wrap it in a task.
这篇关于MS Teams 消息扩展 - 使用另一个任务模块响应 onSubmitAction的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!