如何以团队形式发送o365连接器卡片的旋转木马

时间:2018-04-12 10:19:44

标签: node.js botframework microsoft-teams office365connectors

我正在尝试使用节点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:\项目\ node_modules \ botbuilder \ lib中\ DefaultLocalizer.js:226         return key.replace(/:/ g,&#34; - &#34;)。toLowerCase();

TypeError: key.replace is not a function

我该如何发送此卡。

提前致谢

1 个答案:

答案 0 :(得分:1)

您的代码中存在许多语法错误。这是更新的代码:

        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();