Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to get output in "talk"? #62

Closed
yasinAtlibra opened this issue Nov 15, 2017 · 3 comments
Closed

how to get output in "talk"? #62

yasinAtlibra opened this issue Nov 15, 2017 · 3 comments
Labels

Comments

@yasinAtlibra
Copy link

I have two questions.

  1. Currently, I get user inputs when the conversation with the bot is over, as documentations show.

        bot.on('end', (output, sessionId) => {
                     console.log('User inputs:', output);
        });
    

is there a way to get it in the "talk" event? Note that I am using session.

  1. In rules, we can inject the user’s answers into bot's replies. Is it possible to inject texts from somewhere also? For example, load some text from data base in an custom action of a rule, then inject the text into "replyMessage" of the rule?

I want the second one to display some data dynamically to users, so wondering how to achieve it.

Thanks in advance!

@andersonba
Copy link
Owner

andersonba commented Nov 16, 2017

Hello, @yasinAtlibra !

  1. You can access the store using bot.store.output() or a specific data using bot.store.get('output.name').
bot.on('talk', () => console.log( bot.store.output() ));

Just to remember, talk is event handled by bot message. If you want the event of user reply, use reply event (available in the latest version: 1.10.0).

  1. Currently, only the data from output is considered to compile the message. So, you can inject this data into the store using bot.store.set('output.someData', value) in your custom action.

I'm happy you use it. Your feedback is always welcome. Thank you.

@yasinAtlibra
Copy link
Author

yasinAtlibra commented Nov 16, 2017

@andersonba Hi, you been helpful, thank you 👍
Just one concern, how can I use "sessionId" in them? should it be like

                 bot.session(sessionId).store.output()  // this did not work. 

also in

                bot.store.set('output.someData', value)

, how can I set with "sessionId"?
I am using the bot to talk to multiple users.
or It does not need to use "sessionId" at all?

@andersonba
Copy link
Owner

Sorry about the long delay.
Yeah, for multiple users the session is required.
You need to configure the bot to save the store of users in a DB or send it to the user, sending store in all calls. See socket.io implementation in examples, I always send the store through requests.
I will close this issue, but if you still with questions, reopen it.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants