带有多个按钮的Microsoft bot框架轮播

时间:2018-01-17 10:02:50

标签: node.js botframework chatbot facebook-chatbot

我想使用Microsoft bot框架为facebook messenger制作如下图所示的旋转木马

enter image description here

export function SuboffertCard(subOffert: SubOffertCard, session?: builder.Session) {
return new builder.HeroCard(session)
    .title(subOffert.title)
    .subtitle(subOffert.subtitle)
    .images([
        builder.CardImage.create(session, subOffert.image)
            .tap(builder.CardAction.showImage(session, subOffert.image)),
    ])
    .buttons([
        builder.CardAction.imBack(session, `select:get_${subOffert.title}`, polyglot.t("select")),
        builder.CardAction.imBack(session, `select:info_${subOffert.title}`, polyglot.t("info"))
    ])}

在app.ts中:

 let msg = new builder.Message(session)
            .attachmentLayout(builder.AttachmentLayout.carousel)
            .attachments(subOfferts.map(subOffert => SuboffertCard(subOffert, session)));
         builder.Prompts.choice(session, msg, subOfferts.map(subOffert => `select:get_${subOffert.title} | select:info_${subOffert.title}` ));

但无论我点击哪个按钮,都会收到相同的有效负载。

0 个答案:

没有答案