我创建了可以在我输入特定命令时返回自适应卡的机器人。我已经在Bot Framework Emulator上对其进行了测试,并显示了该卡。
但是当我在Microsoft Teams上对其进行测试时,它返回undefined:
Bot Framework仿真器
Microsoft团队
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);
}
}
Support.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();
};
你能告诉我我在哪里做错了吗?谢谢你。
答案 0 :(得分:0)
我已将 support.js 中的代码更改为:
EXEC sp_configure N'show advanced options', 1
RECONFIGURE WITH OVERRIDE;
EXEC sp_configure N'xp_cmdshell', 1
RECONFIGURE WITH OVERRIDE;
DECLARE @SQL NVARCHAR(MAX) = ''
SET @SQL = N'Execute xp_cmdshell ''bcp "SELECT * FROM Table;" queryout "D:\AzureTableData.txt" -c -t@_@ -S azure.database.windows.net -d DatabaseName -U user1@azure.database.windows.net -P *****"''';
它现在正在工作
答案 1 :(得分:0)
在我的情况下改变这个
let data = {};
data.attachments = [CardFactory.adaptiveCard(dropdown)];
context.sendActivity([CardFactory.adaptiveCard(data)])
到这里
context.sendActivity(MessageFactory.attachment(CardFactory.adaptiveCard(dropdown)))
解决了同样的问题。