Botkit: beginDialog() options argument

Created on 25 Mar 2020  路  4Comments  路  Source: howdyai/botkit

My goal is to pass a variable into the botkit dialog, before it starts.

The documentation says, that beginDialog() has options (optional) argument. I can not find any information, what is this option object supposed to be

If an option object can not be used to pass a variable to the dialog, is there another way to do it?

help wanted

Most helpful comment

This needs documentation!

All 4 comments

You can use it like this:

await bot.beginDialog(SOME_DIALOG, {foo: 'bar', baz: 'foo'})

then inside your dialog, you can access that as convo.vars.foo or in a template as {{vars.foo}}

Great! Thank you!

This needs documentation!

this doesn't work.

    console.log(convo.vars.foo) ;
                           ^

TypeError: Cannot read property 'foo' of undefined
    at module.exports (/Users/Yomaru/apps/botkit/comp4461-botkit/features/shop.js:8:28)
    at Botkit.loadModule (/Users/Yomaru/apps/botkit/comp4461-botkit/node_modules/botkit/lib/core.js:840:13)
    at /Users/Yomaru/apps/botkit/comp4461-botkit/node_modules/botkit/lib/core.js:869:18
    at Array.forEach (<anonymous>)
    at Botkit.loadModules (/Users/Yomaru/apps/botkit/comp4461-botkit/node_modules/botkit/lib/core.js:868:12)
    at Botkit.<anonymous> (/Users/Yomaru/apps/botkit/comp4461-botkit/bot.js:50:16)
    at Botkit.signalBootComplete (/Users/Yomaru/apps/botkit/comp4461-botkit/node_modules/botkit/lib/core.js:393:21)
    at Botkit.completeDep (/Users/Yomaru/apps/botkit/comp4461-botkit/node_modules/botkit/lib/core.js:383:14)
    at Server.<anonymous> (/Users/Yomaru/apps/botkit/comp4461-botkit/node_modules/botkit/lib/core.js:150:26)
    at Object.onceWrapper (events.js:420:28)
Was this page helpful?
0 / 5 - 0 ratings