对于从 TeamsFx 生成的 ConversationBot,我们如何为 cardAction 实现 SSO?我们可以为 Command 使用 ssoCommands,但似乎有用于 cardAction 的 sso。任何人都可以展示一个样本吗?
export const commandBot = new ConversationBot({
// The bot id and password to create CloudAdapter.
// See https://aka.ms/about-bot-adapter to learn more about adapters.
adapterConfig: {
MicrosoftAppId: config.botId,
MicrosoftAppPassword: config.botPassword,
MicrosoftAppType: "MultiTenant",
},
ssoConfig: {
aad: {
scopes: ["User.Read"],
},
},
command: {
enabled: true,
commands: [new HelloWorldCommandHandler()],
ssoCommands: [new ProfileSsoCommandHandler()],
},
cardAction: {
enabled: true,
actions: [
new DoSomethingActionHandler()
],
},
notification: {
enabled: true
}
});
这里有一个sso自适应卡示例:https://github.com/SLdragon/bot-sso-action-card
要使用示例代码,您只需克隆 repo,在 VSCode(安装了 Teams Toolkit 4.x.x)中打开它,然后单击 f5 进行本地调试。
在机器人聊天窗口中,输入“helloworld”消息,它会响应一个自适应卡片,在卡片中,有一个按钮会触发sso action handler。
上面的例子只是为了让sso适用于修改teamsfx sdk的自适应卡的解决方案,它在群聊中不起作用,未来teams toolkit团队将使用新的GA为其提供稳定的解决方案功能描述如下
您还可以尝试通用 sso 卡操作的最新 GA 功能(它现在没有与团队工具包集成,但您可以按照示例项目中的步骤使其工作):
示例项目:https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/bot-sso-adaptivecard/nodejs