Adaptive Card 在 Microsoft Teams 中返回 undefined 但在机器人模拟器中运行良好

里夫基·毛拉纳

我创建了一个机器人,当我输入某个命令时它会返回一个自适应卡。我已经在 Bot Framework Emulator 上对其进行了测试,它显示了该卡。

但是当我在 Microsoft Teams 上对其进行测试时,它返回 undefined :

机器人框架模拟器

在此处输入图片说明

微软团队

在此处输入图片说明 应用程序.js

require('dotenv-extended').load();

var util = require('util');
var builder = require('botbuilder');
var restify = require('restify');

// Setup Restify Server
var server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function () {
    console.log('%s listening to %s', server.name, server.url);
});

// Create chat bot and listen to messages
var connector = new builder.ChatConnector({
    appId: process.env.MICROSOFT_APP_ID,
    appPassword: process.env.MICROSOFT_APP_PASSWORD
});
server.post('/api/messages', connector.listen());

var inMemoryStorage = new builder.MemoryBotStorage();

var bot = new builder.UniversalBot(connector, function (session) {

    if (session.message && session.message.value) {
        // A Card's Submit Action obj was received
        processSubmitAction(session, session.message.value);
        return;
    }
}).set('storage', inMemoryStorage); // Register in memory storage

// Help
bot.dialog('support', require('./support'))
    .triggerAction({
        matches: [/help/i, /support/i, /problem/i]
    });

// log any bot errors into the console
bot.on('error', function (e) {
    console.log('And error ocurred', e);
});

function processSubmitAction(session, value) {
    var defaultErrorMessage = 'Please complete all the field';
    switch (value.type){
        case 'support':
            session.send("Issue Created");
            break;
        default:
            session.send(defaultErrorMessage);
    }
}

支持.js

var builder = require('botbuilder');
module.exports = function (session) {
    var msg = new builder.Message(session)
    .addAttachment({
        contentType: "application/vnd.microsoft.card.adaptive",
        content: {
            type: "AdaptiveCard",
            speak: "<s>Your  meeting about \"Adaptive Card design session\"<break strength='weak'/> is starting at 12:30pm</s><s>Do you want to snooze <break strength='weak'/> or do you want to send a late notification to the attendees?</s>",
               body: [
                {
                    "type": "ColumnSet",
                    "columns": [
                        {
                            "type": "Column",
                            "items": [
                                {
                                    "type": "TextBlock",
                                    "weight": "Bolder",
                                    "text": "Title",
                                    "wrap": true
                                },
                                {
                                    "type": "Input.Text",
                                    "id": "issueName",
                                    "placeholder": "Issue Title"
                                },
                                {
                                    "type": "TextBlock",
                                    "weight": "Bolder",
                                    "text": "Description",
                                    "wrap": true
                                },
                                {
                                    "type": "Input.Text",
                                    "id": "issueDescription",
                                    "placeholder": "Issue Description",
                                    "style": "Email"
                                },
                                {
                                    "type": "TextBlock",
                                    "weight": "Bolder",
                                    "text": "Issue Type"
                                },
                                {
                                    "type": "Input.ChoiceSet",
                                    "id": "issueType",
                                    "placeholder": "Placeholder text",
                                    "choices": [
                                        {
                                            "title": "Bug",
                                            "value": "Bug"
                                        },
                                        {
                                            "title": "Task",
                                            "value": "Task"
                                        },
                                        {
                                            "title": "Improvement",
                                            "value": "Improvement"
                                        },
                                        {
                                            "title": "New Feature",
                                            "value": "New Feature"
                                        }
                                    ],
                                    "style": "expanded"
                                },
                                {
                                    "type": "TextBlock",
                                    "weight": "Bolder",
                                    "text": "Assignee"
                                },
                                {
                                    "type": "Input.Text",
                                    "id": "issueAssignee",
                                    "placeholder": "Assigne Username"
                                }
                            ],
                            "width": 2
                        }
                    ]
                }
            ],
            "actions": [
                {
                    "type": "Action.Submit",
                    "id": "submitBtn",
                    "title": "Submit",
                    "data":{
                        "type":"support"
                    }
                }
            ]
        }
    });
session.send(msg);
session.endDialog();
};

你能告诉我我哪里做错了吗?之前谢谢。

里夫基·毛拉纳

我已将support.js 中的代码更改为:

var builder = require('botbuilder');
module.exports = function (session) {
    // var customMessage = new builder.Message(session)
    // .text("Hello!")
    // .textFormat("plain")
    // .textLocale("en-us");
    var card = {
        'contentType': 'application/vnd.microsoft.card.adaptive',
        'content': {
            "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
            "type": "AdaptiveCard",
            "version": "1.0",
            "body": [
                        {
                            "type": "ColumnSet",
                            "columns": [
                                {
                                    "type": "Column",
                                    "items": [
                                        {
                                            "type": "TextBlock",
                                            "weight": "Bolder",
                                            "text": "Title",
                                            "wrap": true
                                        },
                                        {
                                            "type": "Input.Text",
                                            "id": "issueName",
                                            "placeholder": "Issue Title"
                                        },
                                        {
                                            "type": "TextBlock",
                                            "weight": "Bolder",
                                            "text": "Description",
                                            "wrap": true
                                        },
                                        {
                                            "type": "Input.Text",
                                            "id": "issueDescription",
                                            "placeholder": "Issue Description",
                                            "style": "Email"
                                        },
                                        {
                                            "type": "TextBlock",
                                            "weight": "Bolder",
                                            "text": "Issue Type"
                                        },
                                        {
                                            "type": "Input.ChoiceSet",
                                            "id": "issueType",
                                            "placeholder": "Placeholder text",
                                            "choices": [
                                                {
                                                    "title": "Bug",
                                                    "value": "Bug"
                                                },
                                                {
                                                    "title": "Task",
                                                    "value": "Task"
                                                },
                                                {
                                                    "title": "Improvement",
                                                    "value": "Improvement"
                                                },
                                                {
                                                    "title": "New Feature",
                                                    "value": "New Feature"
                                                }
                                            ],
                                            "style": "expanded"
                                        },
                                        {
                                            "type": "TextBlock",
                                            "weight": "Bolder",
                                            "text": "Assignee"
                                        },
                                        {
                                            "type": "Input.Text",
                                            "id": "issueAssignee",
                                            "placeholder": "Assigne Username"
                                        }
                                    ],
                                    "width": 2
                                }
                            ]
                        }
                    ],
                    "actions": [
                        {
                            "type": "Action.Submit",
                            "id": "submitBtn",
                            "title": "Submit",
                            "data":{
                                "type":"support"
                            }
                        }
                    ]
                }
    };
    var customMessage = new builder.Message(session)
            .addAttachment(card);
// console.log(session);
session.send(customMessage);
session.endDialog();
};

它现在正在工作

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

使用 Microsoft Teams 和 Action.Submit 时如何知道按下了哪个 Adaptive Card 按钮

如何在 Microsoft Teams 中实现翻译连接器(或机器人)?

Teams Bot Adaptive Card action.Submit 返回未定义但适用于 Bot Emulator

无法与Azure或Teams中的QnAMaker机器人对话,但可以在本地使用模拟器

使用Graph API在Microsoft Teams的机器人通道中以机器人的身份向用户发送消息

使用 Graph API 响应 Microsoft Teams 中的机器人调用

Microsoft Teams Card操作启动应用程序选项卡,而不是在默认浏览器中打开页面

使用Python的Microsoft Teams机器人

Microsoft Teams 中的 Stackdriver 监控事件

如何关闭Microsoft Teams中的通知声音?

Windows 视觉效果中的 Microsoft Teams

永久显示Microsoft Teams中的隐藏频道

Gif图片无法在Microsoft Teams中播放

Microsoft Teams中来自卡的Http POST

在瀑布对话框中捕获 Adaptive Card 提交的值

在 Microsoft Teams“Microsoft 365 for business”中创建课程

JavaScript 中的机器人模拟器

在Microsoft Teams中找不到传入的Webhook连接器

在 Microsoft Teams 中为连接器添加配置

Action.Submit on Adaptive Cards 不会调用下一步(不仅在 Microsoft Teams 中工作,在网络聊天中工作):Bot Framework V4

如何在用户操作的 Teams Adaptive Card 上呈现错误消息

MS Teams 中的 Azure 聊天机器人

Microsoft Teams身份验证:无法在Teams Bot(V4 SDK)中检索令牌

Microsoft Teams App - 如何在 Outlook 日历中创建事件?

已保存的邮件不能在Microsoft Teams中未保存

在 Microsoft Teams 中,我可以安排频道的顺序吗?

与Microsoft Teams中的某人通话时自动拒绝来电

Chatbot在Microsoft Teams中未发送回消息

在Microsoft Teams App Studio中,无法更改Bot端点地址