How to use the botbuilder.ThumbnailCard function in botbuilder

To help you get started, we’ve selected a few botbuilder examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sebsylvester / reminder-bot / src / dialogs / help.js View on Github external
module.exports = (session) => {
    const card = new builder.ThumbnailCard(session)
        .buttons(consts.Menus.help.map(el => builder.CardAction.imBack(session, el.title, el.title)));

    const message = new builder.Message(session)
        .text(consts.Prompts.HELP)
        .addAttachment(card);

    // The bot's global action handlers will intercept the tapped button event
    session.endDialog(message);
};
github microsoft / BotBuilder-Samples / Node / core-globalMessageHandlers / bot.js View on Github external
(session, args, next) => {

        const card = new builder.ThumbnailCard(session);
        card.buttons([
            new builder.CardAction(session).title('Add a number').value('Add').type('imBack'),
            new builder.CardAction(session).title('Get help').value('Help').type('imBack'),
        ]).text(`What would you like to do?`);
        
        const message = new builder.Message(session);
        message.addAttachment(card);

        session.send(`Hi there! I'm the calculator bot! I can add numbers for you.`);
        // we can end the conversation here
        // the buttons will provide the appropriate message
        session.endConversation(message);
    },
]).set('storage', inMemoryStorage); // Register in memory storage
github OfficeDev / msteams-samples-hello-world-nodejs / src / messaging-extension.js View on Github external
var faker = require('faker');

        // If the user supplied a title via the cardTitle parameter then use it or use a fake title
        var title = query.parameters && query.parameters[0].name === 'cardTitle'
            ? query.parameters[0].value
            : faker.lorem.sentence();

        let randomImageUrl = "https://loremflickr.com/200/200"; // Faker's random images uses lorempixel.com, which has been down a lot

        // Build the data to send
        var attachments = [];

        // Generate 5 results to send with fake text and fake images
        for (var i = 0; i < 5; i++) {
            attachments.push(
                new builder.ThumbnailCard()
                    .title(title)
                    .text(faker.lorem.paragraph())
                    .images([new builder.CardImage().url(`${randomImageUrl}?random=${i}`)])
                    .toAttachment());
        }

        // Build the response to be sent
        var response = teamsBuilder.ComposeExtensionResponse
            .result('list')
            .attachments(attachments)
            .toResponse();

        // Send the response to teams
        callback(null, response, 200);
    });
};
github pveller / ecommerce-chatbot / app / dialogs / explore.js View on Github external
const cards = slice.map(p =>
    new builder.ThumbnailCard(session)
      .title(p.title)
      .subtitle(`$${p.price}`)
      .text(p.description)
      .buttons([
        builder.CardAction.postBack(session, `@show:${p.id}`, 'Show me')
      ])
      .images([
        builder.CardImage.create(session, p.image).tap(
          builder.CardAction.postBack(session, `@show:${p.id}`)
        )
      ])
  );
github microsoft / BotBuilder-Samples / Node / cards-CarouselCards / app.js View on Github external
function getCardsAttachments(session) {
    return [
        new builder.HeroCard(session)
            .title('Azure Storage')
            .subtitle('Offload the heavy lifting of data center management')
            .text('Store and help protect your data. Get durable, highly available data storage across the globe and pay only for what you use.')
            .images([
                builder.CardImage.create(session, 'https://docs.microsoft.com/en-us/aspnet/aspnet/overview/developing-apps-with-windows-azure/building-real-world-cloud-apps-with-windows-azure/data-storage-options/_static/image5.png')
            ])
            .buttons([
                builder.CardAction.openUrl(session, 'https://azure.microsoft.com/en-us/services/storage/', 'Learn More')
            ]),

        new builder.ThumbnailCard(session)
            .title('DocumentDB')
            .subtitle('Blazing fast, planet-scale NoSQL')
            .text('NoSQL service for highly available, globally distributed apps—take full advantage of SQL and JavaScript over document and key-value data without the hassles of on-premises or virtual machine-based cloud database options.')
            .images([
                builder.CardImage.create(session, 'https://docs.microsoft.com/en-us/azure/documentdb/media/documentdb-introduction/json-database-resources1.png')
            ])
            .buttons([
                builder.CardAction.openUrl(session, 'https://azure.microsoft.com/en-us/services/documentdb/', 'Learn More')
            ]),

        new builder.HeroCard(session)
            .title('Azure Functions')
            .subtitle('Process events with a serverless code architecture')
            .text('An event-based serverless compute experience to accelerate your development. It can scale based on demand and you pay only for the resources you consume.')
            .images([
                builder.CardImage.create(session, 'https://msdnshared.blob.core.windows.net/media/2016/09/fsharp-functions2.png')
github OfficeDev / microsoft-teams-sample-auth-node / src / dialogs / RootDialog.ts View on Github external
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);
    }
}
github FranckyC / SharePointBot / server.js View on Github external
_.each(results, function(value) {

                        var title = _.find(value.Cells.results, function(o) { return o.Key === "Title"; }).Value;
                        var link = builder.CardAction.openUrl(session, 
                            _.find(value.Cells.results, function(o) { return o.Key === "Path"; }).Value,
                            'View')
                        var fileType = _.find(value.Cells.results, function(o) { return o.Key === "FileType"; }).Value;
                        var hitHighlightedSummary = _.find(value.Cells.results, function(o) { return o.Key === "HitHighlightedSummary"; }).Value;
                        hitHighlightedSummary = hitHighlightedSummary.replace(/|<\/c0>/g,"").replace(//g,"");
                        var elt = new builder.ThumbnailCard(session).title(title).text(_.unescape(hitHighlightedSummary)).subtitle("Type: " + fileType).buttons([link]);

                        cards.push(elt);       
                    });
github sebsylvester / reminder-bot / src / dialogs / showReminders.js View on Github external
const cards = res.map((reminder) => {
                return new builder.ThumbnailCard(session)
                    .title(reminder.value)
                    .subtitle(utils.convertTimestamp(reminder.expiration, timeZoneId))
                    .buttons([ builder.CardAction.dialogAction(session, 'deleteReminder', reminder.id, 'Delete reminder') ]);
            });
github pveller / ecommerce-chatbot / app / dialogs / showCart.js View on Github external
const cards = cart.map(item =>
    new builder.ThumbnailCard(session)
      .title(item.product.title)
      .subtitle(`$${item.variant.price}`)
      .text(
        `${item.variant.color ? 'Color -' + item.variant.color + '\n' : ''}` +
          `${item.variant.size ? 'Size -' + item.variant.size : ''}` ||
          item.product.description
      )
      .buttons([
        builder.CardAction.imBack(
          session,
          `@remove:${item.variant.id}`,
          'Remove'
        )
      ])
      .images([builder.CardImage.create(session, item.variant.image)])
  );