我正在开发一个 MS 团队应用程序,当用户输入某些命令时,该应用程序主要呈现自适应卡片。已使用 Teams Toolkit 创建聊天命令机器人。
一张自适应卡呈现一个表单,底部有一个提交操作按钮。无论我做什么,我都无法将用户输入的值返回到 Javascript 应用程序。
这是自适应卡的代码:
import { AdaptiveCards } from "@microsoft/adaptivecards-tools";
import { CardFactory, MessageFactory } from "botbuilder";
export class MyCommandHandler {
triggerPatterns = "my-trigger";
async handleCommandReceived(context, message) {
// Message sender (full name)
const sender = await context._activity.from.name;
// Adaptive card with dynamic values
const card = {
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"size": "Default",
"weight": "Bolder",
"text": "Header"
},
{
"type": "Input.ChoiceSet",
"choices": [
{
"title": "Choice 1",
"value": "Choice 1"
},
{
"title": "Choice 2",
"value": "Choice 2"
}
],
"placeholder": "choose",
"label": "Task:",
"spacing": "Medium",
"id": "dropdown-task",
"isRequired": true,
"value": "Choice 1"
},
{
"type": "Input.Date",
"label": "Date:",
"isRequired": true,
"id": "date"
},
{
"type": "Input.Time",
"label": "Time:",
"isRequired": true,
"id": "time",
"value": "09:00"
},
{
"type": "Input.ChoiceSet",
"choices": [
{
"title": "Choice 11",
"value": "Choice 11"
},
{
"title": "Choice 22",
"value": "Choice 22"
}
],
"placeholder": "Choose",
"id": "dropdown-time-spent",
"label": "Time spent:",
"isRequired": true,
"value": "Choice 11"
},
{
"type": "Input.Text",
"placeholder": "Placeholder text",
"isRequired": true,
"id": "description",
"label": "Description:",
"isMultiline": true,
"value": "Description goes here"
},
{
"type": "ActionSet",
"actions": [
{
"type": "Action.Submit",
"title": "Submit",
"style": "positive",
"id": "submit-btn"
}
],
"id": "action-set"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.4"
}
const cardData = {
title: "Command is added",
body: "You have responded to the command"
}
const cardJson = AdaptiveCards.declare(card).render(cardData);
return MessageFactory.attachment(CardFactory.adaptiveCard(cardJson));
}
}
是否还有另一个异步函数负责处理提交事件?我在官方文档中找不到任何相关内容。
谢谢!
使用更新的Action.Execute