简体   繁体   English

如何使用 bot 框架在 bot.on 中放置轮播?

[英]how can i put a carousel in bot.on with bot framework?

I have a chatbot with bot framework and I want to have this for my first message in bot.on but I don't know how can I do it.我有一个带有机器人框架的聊天机器人,我想在bot.on中的第一条消息中使用它,但我不知道该怎么做。

Choose your language / Choisissez votre langue:选择您的语言 / Choisissez votre 语言:

(img "flag french") | (img "法国国旗") | (img "flag english") | (img "国旗英语") | (img "flag spanish") (img“西班牙国旗”)

button "français" |按钮“法语” | button "english" |按钮“英文” | button "spanish"按钮“西班牙语”

bot.on('conversationUpdate', function (message) {
    if (message.membersAdded) {
        message.membersAdded.forEach((identity) => {
            if (identity.id == message.address.bot.id) {
                CODE HERE
            }
        });
    }
});

Should I use a carousel with 3 card?我应该使用带 3 张卡的旋转木马吗? but I don't know how to do it in bot.on但我不知道如何在bot.on中做到这一点

Does anyone know how to do it?有谁知道该怎么做?

ok, I find it !好的,我找到了!

bot.on('conversationUpdate', function (message) {
    if (message.membersAdded) {
        message.membersAdded.forEach((identity) => {
            if (identity.id == message.address.bot.id && message.source != 'skypeforbusiness') {
                console.log(message);
                bot.send(new builder.Message()
                    .address(message.address)
                    .text('Choose your language :')
                );
                setTimeout(function () {
                    bot.send(new builder.Message()
                        .address(message.address)
                        .attachmentLayout(builder.AttachmentLayout.carousel)
                        .attachments([
                            new builder.HeroCard()
                                .title()
                                .subtitle()
                                .text()
                                .images([builder.CardImage.create(null, '')])
                                .buttons([
                                    builder.CardAction.imBack(null, "English", "English")
                                ]),
                            new builder.HeroCard()
                                .title()
                                .subtitle()
                                .text()
                                .images([builder.CardImage.create(null, '')])
                                .buttons([
                                    builder.CardAction.imBack(null, "Français")
                                ]),
                            new builder.HeroCard()
                                .title()
                                .subtitle()
                                .text()
                                .images([builder.CardImage.create(null, '')])
                                .buttons([
                                    builder.CardAction.imBack(null, "Español", "Español")
                                ])
                        ])
                    );
                }, 1000);
            }
        });
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM