我如何在团队中发送 o365 连接器卡的轮播
How can i send carousel of o365 connector cards in teams
我正在尝试使用节点 js 在团队中发送 o365 连接器卡的轮播。
可能吗 ?
我写了这段代码
var cards = [];
for(var i=1; i<4; i++)
{
let choice = "choice";
let cardAction2 = new teams.O365ConnectorCardActionCard(session)
.id("cardAction-2")
.name("Create")
.inputs([
new teams.O365ConnectorCardTextInput(session)
.id("text-1")
.title("write your comment here....")
.isMultiline(true),
])
.actions([
new teams.O365ConnectorCardHttpPOST(session)
.id("cardAction-2-btn-1")
.name("send")
.body(JSON.stringify({
text1: "{{text-1.value}}",
})),
]);
let card = new teams.O365ConnectorCard(session)
.summary("o365_card_summary")
.themeColor("#E67A9E")
.title("Open ")
.potentialAction([
cardAction2,
]);
let msg2 = new teams.TeamsMessage(session)
.summary("message summary")
.attachments([card])
cards.push(msg2);
session.send(cards)
但是我在 运行 项目
时遇到错误
D:\project\node_modules\botbuilder\lib\DefaultLocalizer.js:226
return key.replace(/:/g, "--").toLowerCase();
TypeError: key.replace is not a function
我怎么寄这张卡
提前致谢
您的代码中有很多语法错误。这是更新的代码:
var cards = [];
for(var i=1; i<4; i++)
{
let choice = "choice";
let cardAction2 = new teams.O365ConnectorCardActionCard(session)
.id("cardAction-2")
.name("Create")
.inputs([
new teams.O365ConnectorCardTextInput(session)
.id("text-1")
.title("write your comment here....")
.isMultiline(true)
])
.actions([
new teams.O365ConnectorCardHttpPOST(session)
.id("cardAction-2-btn-1")
.name("send")
.body(JSON.stringify({
text1: "{{text-1.value}}"
})),
]);
let card = new teams.O365ConnectorCard(session)
.summary("o365_card_summary")
.themeColor("#E67A9E")
.title("Open ")
.potentialAction([
cardAction2
]);
cards.push(card);
}
let msg2 = new teams.TeamsMessage(session)
.summary("message summary")
.attachments(cards);
msg2.attachmentLayout(builder.AttachmentLayout.carousel)
session.send(msg2).endDialog();
我正在尝试使用节点 js 在团队中发送 o365 连接器卡的轮播。 可能吗 ? 我写了这段代码
var cards = [];
for(var i=1; i<4; i++)
{
let choice = "choice";
let cardAction2 = new teams.O365ConnectorCardActionCard(session)
.id("cardAction-2")
.name("Create")
.inputs([
new teams.O365ConnectorCardTextInput(session)
.id("text-1")
.title("write your comment here....")
.isMultiline(true),
])
.actions([
new teams.O365ConnectorCardHttpPOST(session)
.id("cardAction-2-btn-1")
.name("send")
.body(JSON.stringify({
text1: "{{text-1.value}}",
})),
]);
let card = new teams.O365ConnectorCard(session)
.summary("o365_card_summary")
.themeColor("#E67A9E")
.title("Open ")
.potentialAction([
cardAction2,
]);
let msg2 = new teams.TeamsMessage(session)
.summary("message summary")
.attachments([card])
cards.push(msg2);
session.send(cards)
但是我在 运行 项目
时遇到错误D:\project\node_modules\botbuilder\lib\DefaultLocalizer.js:226 return key.replace(/:/g, "--").toLowerCase();
TypeError: key.replace is not a function
我怎么寄这张卡
提前致谢
您的代码中有很多语法错误。这是更新的代码:
var cards = [];
for(var i=1; i<4; i++)
{
let choice = "choice";
let cardAction2 = new teams.O365ConnectorCardActionCard(session)
.id("cardAction-2")
.name("Create")
.inputs([
new teams.O365ConnectorCardTextInput(session)
.id("text-1")
.title("write your comment here....")
.isMultiline(true)
])
.actions([
new teams.O365ConnectorCardHttpPOST(session)
.id("cardAction-2-btn-1")
.name("send")
.body(JSON.stringify({
text1: "{{text-1.value}}"
})),
]);
let card = new teams.O365ConnectorCard(session)
.summary("o365_card_summary")
.themeColor("#E67A9E")
.title("Open ")
.potentialAction([
cardAction2
]);
cards.push(card);
}
let msg2 = new teams.TeamsMessage(session)
.summary("message summary")
.attachments(cards);
msg2.attachmentLayout(builder.AttachmentLayout.carousel)
session.send(msg2).endDialog();