iT邦幫忙

2018 iT 邦幫忙鐵人賽
DAY 10
0

全域呼叫終斷原本的dialog流程,這個部份去年coding的時候,還沒有。

// The dialog stack is cleared and this dialog is invoked when the user enters 'help'.
bot.dialog('help', function (session, args, next) {
    session.endDialog("This is a bot that can help you make a dinner reservation. <br/>Please say 'next' to continue");
})
.triggerAction({
    matches: /^help$/i,
});
bot.dialog('help', function (session, args, next) {
    session.endDialog("This is a bot that can help you make a dinner reservation. <br/>Please say 'next' to continue");
})
.triggerAction({
    matches: /^help$/i,
    onSelectAction: (session, args, next) => {
        // Add the help dialog to the dialog stack 
        // (override the default behavior of replacing the stack)
        session.beginDialog(args.action, args);
    }
});

這兩個範例都可以全域呼叫,
差別在於 onSelectAction 不會終止原本的dialog流程,結束之後,還是會回到原本的dialog.


上一篇
Manage a conversation flow with multiple dialogs
系列文
Microsoft Bot Framework 30天上手12
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言