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


TypeScript botbuilder.CardAction类代码示例

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


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

示例1: getSuggestedActions

function getSuggestedActions(session: Session): SuggestedActions {
    const yes = session.localizer.gettext(session.preferredLocale(), 'confirmation.yesOption');
    const no = session.localizer.gettext(session.preferredLocale(), 'confirmation.noOption');
    const cancel = session.localizer.gettext(session.preferredLocale(), 'confirmation.cancelOption');
    return SuggestedActions.create(session, [
        CardAction.imBack(session, yes, yes),
        CardAction.imBack(session, no, no),
        CardAction.imBack(session, cancel, cancel)]);
}
开发者ID:magencio,项目名称:UberBotNode_V3,代码行数:9,代码来源:confirmationPrompt.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: getSuggestedActions

function getSuggestedActions(session: Session): SuggestedActions {
    const faq = session.localizer.gettext(session.preferredLocale(), 'master.faqOption');
    const feedback = session.localizer.gettext(session.preferredLocale(), 'master.feedbackOption');
    const complaints = session.localizer.gettext(session.preferredLocale(), 'master.complaintsOption');
    const language = session.localizer.gettext(session.preferredLocale(), 'master.languageOption');
    return SuggestedActions.create(session, [
        CardAction.imBack(session, faq, faq),
        CardAction.imBack(session, feedback, feedback),
        CardAction.imBack(session, complaints, complaints),
        CardAction.imBack(session, language, language)]);
}
开发者ID:magencio,项目名称:UberBotNode_V3,代码行数:11,代码来源:masterDialog.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: step1

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

        if (isMessageFromChannel(session.message)) {
            // create button to deep link to the configurable channel tab - configurable channel tab must have been added for this to work
            // pattern for configurable channel tab deep link:
            // https://teams.microsoft.com/l/entity/APP_ID/ENTITY_ID?webUrl=ENTITY_WEB_URL&label=<entityLabel>&context=CONTEXT
            // APP_ID is the appId assigned in the manifest
            // ENTITY_ID is the entityId that is set for that channel tab when your config page creates it
            // ENTITY_WEB_URL is a url that is opened in a browswer on a mobile device if this url is opened on a mobile device
            // CONTEXT is a url encoded json object with a channelId parameter inside of it
            let appId = config.get("app.appId");
            let configTabEntityId = "test123";
            let queryParams = querystring.stringify({ context: "{\"channelId\":\"" + session.message.sourceEvent.channel.id + "\"}" });
            let configTabHardCodedUrl = "https://teams.microsoft.com/l/entity/" + appId + "/" + configTabEntityId + "?" + queryParams;
            buttons.push(builder.CardAction.openUrl(session, configTabHardCodedUrl, Strings.open_configurable_tab));
        }

        // create a button to deep link to the static tab located in the 1:1 chat with the bot
        // pattern for static tab deep link:
        // (at a minimum to get to the static tab)
        // https://teams.microsoft.com/l/entity/28:BOT_ID/ENTITY_ID?conversationType=chat

        // (for sending data to that tab) - look at the HelpDialog for an example
        // https://teams.microsoft.com/l/entity/28:BOT_ID/ENTITY_ID?conversationType=chat&context=CONTEXT

        // BOT_ID is the bot id that comes from your bot registration with 28: added to the front
        // ENTITY_ID is the entityId that is set for that static tab in the manifest
        // CONTEXT is a url encoded json object with a subEntityId parameter inside of it – this is how you can pass data to your static tab
        // e.g. %7B%22subEntityId%22%3A%22SUB_ENTITY_ID_DATA%22%7D
        let botId = "28:" + config.get("bot.botId");
        let staticTabEntityId = "1on1test123"; // this comes from the manifest file
        let queryParams = querystring.stringify(
            {
                conversationType: "chat",
                context: JSON.stringify({ subEntityId: "stuff" }),
            },
        );
        let staticTabHardCodedUrl = "https://teams.microsoft.com/l/entity/" + botId + "/" + staticTabEntityId + "?" + queryParams;
        buttons.push(builder.CardAction.openUrl(session, staticTabHardCodedUrl, Strings.open_static_tab));

        let newCard = new builder.HeroCard(session)
            .text(Strings.deeplink_card_text, staticTabHardCodedUrl)
            .buttons(buttons);

        session.send(new builder.Message(session)
            .addAttachment(newCard));

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

示例6: showUserProfile

    // Show user profile
    protected async showUserProfile(session: builder.Session): Promise<void> {
        let linkedInApi = this.authProvider as GoogleProvider;
        let userToken = this.getUserToken(session);

        if (userToken) {
            let profile = await linkedInApi.getProfileAsync(userToken.accessToken, [ "names", "emailAddresses", "photos", "urls" ]);

            let name = this.findPrimaryValue(profile.names);
            let email = this.findPrimaryValue(profile.emailAddresses);
            let photo = this.findPrimaryValue(profile.photos);
            let profileUrl = this.findPrimaryValue(profile.urls);

            let profileCard = new builder.ThumbnailCard()
                .title(name.displayName)
                .subtitle(email.value)
                .buttons([
                    builder.CardAction.openUrl(session, profileUrl.value, "View on Google"),
                ])
                .images([
                    new builder.CardImage()
                        .url(photo.url)
                        .alt(name.displayName),
                ]);
            session.send(new builder.Message().addAttachment(profileCard));
        } else {
            session.send("Please sign in to Google so I can access your profile.");
        }

        await this.promptForAction(session);
    }
开发者ID:billbliss,项目名称:microsoft-teams-sample-auth-node,代码行数:31,代码来源:GoogleDialog.ts

示例7: showUserProfile

    // Show user profile
    protected async showUserProfile(session: builder.Session): Promise<void> {
        let linkedInApi = this.authProvider as LinkedInProvider;
        let userToken = this.getUserToken(session);

        if (userToken) {
            let profile = await linkedInApi.getProfileAsync(userToken.accessToken, [ "formatted-name", "headline", "picture-url", "public-profile-url", "location", "num-connections", "num-connections-capped" ]);
            let profileCard = new builder.ThumbnailCard()
                .title(profile.formattedName)
                .subtitle(profile.headline)
                .text(`${profile.location.name} • ${profile.numConnections}${profile.numConnectionsCapped ? "+" : ""} connections`)
                .buttons([
                    builder.CardAction.openUrl(session, profile.publicProfileUrl, "View on LinkedIn"),
                ])
                .images([
                    new builder.CardImage()
                        .url(profile.pictureUrl)
                        .alt(profile.formattedName),
                ]);
            session.send(new builder.Message().addAttachment(profileCard));
        } else {
            session.send("Please sign in to LinkedIn so I can access your profile.");
        }

        await this.promptForAction(session);
    }
开发者ID:billbliss,项目名称:microsoft-teams-sample-auth-node,代码行数:26,代码来源:LinkedInDialog.ts

示例8: 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

示例9: step1

    private static async step1(session: builder.Session, args?: any | builder.IDialogResult<any>, next?: (args?: builder.IDialogResult<any>) => void): Promise<void> {
        let buttons = new Array<builder.CardAction>();
        let botId = "28:" + config.get("bot.botId");
        let staticTabEntityId = "1on1test123"; // this comes from the manifest file
        let queryParams = querystring.stringify(
            {
                conversationType: "chat",
                // context: "{\"subEntityId\":\"allCommands\"}",
                context: JSON.stringify({ subEntityId: "allCommands" }),
            },
        );

        // hardCodedUrl has url encoded {"subEntityId":"allCommands"} set as the context
        let staticTabHardCodedUrl = "https://teams.microsoft.com/l/entity/" + botId + "/" + staticTabEntityId + "?" + queryParams;
        buttons.push(builder.CardAction.openUrl(session, staticTabHardCodedUrl, Strings.all_commands_button));

        let newCard = new builder.HeroCard(session)
            .text(Strings.help_msg)
            .buttons(buttons);

        session.send(new builder.Message(session)
            .addAttachment(newCard));

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

示例10:

 (session: any, results: any) => {
     session.send('I am looking for the nearest store to ' + results.response + ', please wait a few seconds');
     session.send('Oh and based on what you need I can also recommand that you get a Office 365 subscription, are you interested in this?');
     var msg = new builder.Message(session)
             .textFormat(builder.TextFormat.xml)
             .attachmentLayout(builder.AttachmentLayout.carousel)
             .attachments([
                 new builder.HeroCard(session)
                     .title("Special Offer")
                     .text("Add an Office 365 subscription?")
                     .images([])
                     .buttons([
                         builder.CardAction.imBack(session, "Yes", "Yes"),
                         builder.CardAction.imBack(session, "No", "No")
                     ])
             ]);
         builder.Prompts.choice(session, msg, "Yes|No");
 },
开发者ID:DXFrance,项目名称:botretail,代码行数:18,代码来源:retailbot.dialogsManager.ts


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