broidHQ / integrations

Connect your App to Multiple Messaging Channels with the W3C Open standard.
https://www.broid.ai
GNU Affero General Public License v3.0
746 stars 83 forks source link

Conversations, dialogs, router, actions, etc. #176

Closed lesyk closed 7 years ago

lesyk commented 7 years ago

Overview

Details

I used Botframework from Microsoft for a while, there they have concepts like conversations, dialogs, router, actions, etc., are there any plans to implement them here? If not, what would you suggest to use for having such abstractions?

Currently I am struggling to make architecture, where bot can have more than one message conversation. How usually it is done with this framework? Back in botframework, they use waterfall model of conversation, what is the paradigm here?

killix commented 7 years ago

I need to check in details how it really works with botframework. But as you can see we use a conversation id in a context object to make the possibility of the bot/app to route the answer correctly.

About dialogs, router, actions it's something we support in others integrations, we need to add it in the MS integrations (Skype and MS Teams).

lesyk commented 7 years ago

Here are really important (to me) concepts:

Waterflow

In botframeworks to crate dialog I would do some thing like this:

bot.dialog('greetings', [
    // Step 1
    function (session) {
        builder.Prompts.text(session, 'Hi! What is your name?');
    },
    // Step 2
    function (session, results) {
        session.endDialog('Hello %s!', results.response);
    }
]);

Thus, as soon as I am in greetings dialog, bot asks about name, use reply, and then it prints it.

Dialog

bot.dialog('greetings', [
    function (session) {
        session.beginDialog('askName');
    },
    function (session, results) {
        session.endDialog('Hello %s!', results.response);
    }
]);
bot.dialog('askName', [
    function (session) {
        builder.Prompts.text(session, 'Hi! What is your name?');
    },
    function (session, results) {
        if(results.response){         
          session.endDialogWithResult({
            response: null,
            resumed: builder.ResumeReason.back
          });
        }
   }
]);

In this example, chats begins from greetings dialog; where bot starts dialog askName, thus, user gets question 'Hi! What is your name?', when user replies, answer is pushed back to greetings dialog and message 'Hello...' shown.

Maybe I am asking wrong questions, but with current setup it is unclear for me how to implement those concepts. The only solution which I see now is to save in nodejs's memory all users and stages of their conversations. So, as soon as new text is sent I do look up by user id fetch dialog id (place where message was sent last time) and direct that communication to that place. Your thoughts?

As I understand conversation id is not the answer for me, since it is basically binding between user and chat/channel.