facebook-messengerbotkit

Is there a way to use variables inside a Botkit dialog?


I'm trying to make a dialog which shows a dynamic carousel with botkit.

I want the items in this carousel to change according to data on a JSON, I already have a function which creates and updates an "attachmentJSON" variable in the correct format using the data from the original JSON, so it should look something like this:

dialog.ask({ "attachment": attachmentJSON }

The function that updates attachmentJSON is called by several different 'bot.hears' on runtime. Is there a way to do what I'm trying to do?


Solution

  • I really doubt it's the best solution, but what I ended up doing is creating a function which overwrites the dialog using the updated JSON, and call this "updateConversation" function everytime I need it.

    It works at the very least.