1

有人可以帮助如何处理自适应卡中的 2 个提交操作吗?如果用户单击接受按钮,则必须启动另一个对话框。如果用户单击拒绝按钮,则必须启动重新启动对话框。

json布局

        "actions": [
        {
            "type": "Action.Submit",
            "title": "Accept",
            "data": { "choice": "Accept"}
        },
        {
            "type": "Action.Submit",
            "title": "Decline",
            "data": { "choice": "Decline"}
        }
    ]

代码:

bot.dialog('overview', function (session, options) {
    if (session.message && session.message.value) {
        if(choice == "Accept"){
            session.beginDialog('otherDialog');
        } else if (choice == "Decline"){
            session.beginDialog('restart');
        }
        return;
    }
4

1 回答 1

1

选择将是.value上的属性

bot.dialog('overview', function (session, options) {
    if (session.message && session.message.value) {
        session.endDialog();
        switch (session.message.value.choice) {
            case 'Accept':
                session.beginDialog('otherDialog');
                break;
            case 'Decline':
                session.beginDialog('restart');
                break;                
          }             
        return;
    }else{
        //show the card, since there has not been a choice
        var cardMessage  = require('./overviewCard.json');
        cardMessage.address = session.message.address
        bot.send(cardMessage)
    }
})
于 2017-12-07T23:50:19.433 回答