-2

我正在尝试使用节点 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

我怎样才能发送这张卡。

提前致谢

4

1 回答 1

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();
于 2018-04-12T11:29:34.827 回答