当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript CardAction.messageBack方法代码示例

本文整理汇总了TypeScript中botbuilder.CardAction.messageBack方法的典型用法代码示例。如果您正苦于以下问题:TypeScript CardAction.messageBack方法的具体用法?TypeScript CardAction.messageBack怎么用?TypeScript CardAction.messageBack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在botbuilder.CardAction的用法示例。


在下文中一共展示了CardAction.messageBack方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: setupCardMessage

    // setup the card message and then user can update the card using below update dialog file
    // microsoft-teams-sample-complete-node\src\dialogs\examples\teams\UpdateCardMsgDialog.ts
    private static async setupCardMessage(session: builder.Session, args?: any | builder.IDialogResult<any>, next?: (args?: builder.IDialogResult<any>) => void): Promise<void> {
        let updateCardCounter = 0;

        let messageBackButtonValue = JSON.stringify({ updateCounterKey: updateCardCounter });
        let messageBackButton = builder.CardAction.messageBack(session, messageBackButtonValue)
            .displayText(Strings.messageBack_button_display_text)
            .title(Strings.update_card_button)
            .text("update card message"); // This must be a string that routes to UpdateCardMsgDialog, which handles card updates

        let card = new builder.HeroCard(session)
            .title(Strings.default_title)
            .subtitle(Strings.default_subtitle)
            .text(Strings.default_text)
            .images([
                new builder.CardImage(session)
                    .url(config.get("app.baseUri") + "/assets/computer_person.jpg")
                    .alt(session.gettext(Strings.img_default)),
                ])
            .buttons([messageBackButton]);

        let msg = new builder.Message(session)
            .addAttachment(card);

        session.endDialog(msg);
    }
开发者ID:gvprime,项目名称:microsoft-teams-sample-complete-node,代码行数:27,代码来源:UpdateCardMsgSetupDialog.ts

示例2: step1

    private static async step1(session: builder.Session, args?: any | builder.IDialogResult<any>, next?: (args?: builder.IDialogResult<any>) => void): Promise<void> {
        let cards = new Array<builder.ThumbnailCard>();
        let numbCards = 3;

        for (let i = 0; i < numbCards; i++) {
            let buttons = new Array<builder.CardAction>();
            /**
             * This is an example of a button using invoke to begin a new dialog
             * the response field is used as a way to pass data to the newly begun dialog
             * the response field is not needed
             *
             * This is an example of getting the input data from the args
             * when dialog is begun with beginDialog()
             */
            // let input = "";
            // if (args.response) {
            //     input = args.response;
            // }
            buttons.push(new builder.CardAction(session)
                .type("invoke")
                .title(Strings.invoke_button_hello_dialog)
                .value("{" +
                    "\"dialog\": \"" + DialogIds.HelloDialogId + "\", " +
                    "\"response\": \"Information for called intent\"" +
                "}"),
            );

            buttons.push(builder.CardAction.imBack(session, session.gettext(Strings.hello_imback), Strings.imback_button_hello_dialog));

            let messageBackButtonValue = JSON.stringify({ anything: "abc12345" });
            let messageBackButton = builder.CardAction.messageBack(session, messageBackButtonValue, Strings.messageBack_button_title)
                .displayText(Strings.messageBack_button_display_text)
                .text(Strings.messageBack_button_text); // this matches match for MessageBackReceiverDialog
            buttons.push(messageBackButton);

            let newCard = new builder.ThumbnailCard(session)
                .title(Strings.default_title)
                .subtitle(Strings.default_subtitle)
                .text(Strings.default_text)
                .images([
                    new builder.CardImage(session)
                        .url(config.get("app.baseUri") + "/assets/computer_person.jpg")
                        .alt(session.gettext(Strings.img_default)),
                ])
                .buttons(buttons)
                .tap(builder.CardAction.imBack(session, session.gettext(Strings.hello_imback)));

            cards.push(newCard);
        }

        session.send(new builder.Message(session)
            // .attachmentLayout("list")
            .attachmentLayout("carousel")
            .attachments(cards));

        session.endDialog();
    }
开发者ID:gvprime,项目名称:microsoft-teams-sample-complete-node,代码行数:57,代码来源:ThumbnailCardDialog.ts

示例3: promptForAction

 // Show prompt of options
 protected async promptForAction(session: builder.Session): Promise<void> {
     let msg = new builder.Message(session)
         .addAttachment(new builder.ThumbnailCard(session)
             .title(this.providerDisplayName)
             .buttons([
                 builder.CardAction.messageBack(session, "{}", "Sign in")
                     .text("SignIn")
                     .displayText("Sign in"),
                 builder.CardAction.messageBack(session, "{}", "Show profile")
                     .text("ShowProfile")
                     .displayText("Show profile"),
                 builder.CardAction.messageBack(session, "{}", "Sign out")
                     .text("SignOut")
                     .displayText("Sign out"),
                 builder.CardAction.messageBack(session, "{}", "Back")
                     .text("Back")
                     .displayText("Back"),
             ]));
     session.send(msg);
 }
开发者ID:billbliss,项目名称:microsoft-teams-sample-auth-node,代码行数:21,代码来源:BaseIdentityDialog.ts

示例4: promptForIdentityProvider

 // Prompt the user to pick an identity provider
 private promptForIdentityProvider(session: builder.Session): void {
     let msg = new builder.Message(session)
         .addAttachment(new builder.ThumbnailCard(session)
             .title("Select an identity provider")
             .buttons([
                 builder.CardAction.imBack(session, "LinkedIn", "LinkedIn"),
                 builder.CardAction.messageBack(session, "{}", "AzureAD (v1)")
                     .displayText("AzureAD (v1)")
                     .text("AzureADv1"),
                 builder.CardAction.imBack(session, "Google", "Google"),
             ]));
     session.send(msg);
 }
开发者ID:billbliss,项目名称:microsoft-teams-sample-auth-node,代码行数:14,代码来源:RootDialog.ts

示例5: updateCardMessage

    // update the card, if user has already setup the card message from below dialog file using update button click
    // microsoft-teams-sample-complete-node\src\dialogs\examples\teams\UpdateCardMsgSetupDialog.ts
    private static async updateCardMessage(session: builder.Session, args?: any | builder.IDialogResult<any>, next?: (args?: builder.IDialogResult<any>) => void): Promise<void> {
        if (session.message.replyToId)
        {
            let updateCardCounter = session.message.value.updateCounterKey;
            let messageBackButtonValue = JSON.stringify({ updateCounterKey: ++updateCardCounter });

            let messageBackButton = builder.CardAction.messageBack(session, messageBackButtonValue)
                .displayText(Strings.messageBack_button_display_text)
                .title(Strings.update_card_button)
                .text("update card message"); // This must be a string that routes to UpdateCardMsgDialog, which handles card updates

            let newCard = new builder.HeroCard(session)
                .title(Strings.updated_card_title, updateCardCounter)
                .subtitle(Strings.updated_card_subtitle)
                .text(Strings.default_text)
                .images([
                    new builder.CardImage(session)
                        .url(config.get("app.baseUri") + "/assets/computer_person.jpg")
                        .alt(session.gettext(Strings.img_default)),
                    ])
                .buttons([messageBackButton]);

            let addressOfMessageToUpdate = { ...session.message.address, id: session.message.replyToId };

            let msg = new builder.Message(session)
                .address(addressOfMessageToUpdate)
                .addAttachment(newCard);

            session.connector.update(msg.toMessage(), (err, address) => {
                if (!err) {
                    session.send(Strings.updated_msg_confirmation);
                } else {
                    session.send(Strings.update_card_error + err.message);
                }
                session.endDialog();
            });
        }
        else
        {
            session.send(Strings.no_msg_to_update);
            session.endDialog();
        }
    }
开发者ID:gvprime,项目名称:microsoft-teams-sample-complete-node,代码行数:45,代码来源:UpdateCardMsgDialog.ts


注:本文中的botbuilder.CardAction.messageBack方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。