0

For the chatbot, it is simple to implement a webhooks event for a single event such as:

If option A, send X
If option B, send Y
If Option C, send Z

However, what if the next event should be based off the previous event. Such as there are options listed as:

A)
   1
   2
   3
B)
   1
   2
   3

Where you have to first send a letter, and then send a number. So if I want to choose B2, I have to send B, and then 2. However, it needs a way to remember the B choice. The way webhooks is implemented, the next message starts the program over so instead of the number, it would expect the letter again from the beginning.

If it was plain python, I would use the input() method after the first letter choice to wait for the number choice, but this method isn't an available option in webhooks as it breaks the program.

I would assume that there needs to be some sort of database for this, where letter choice is remembered and can then choose a number. I am running my webhooks through Heroku and would like insight for how this can be implemented if via database or if anyone can suggest a different method.

Lev
  • 81
  • 1
  • 10

1 Answers1

0

I can suggest you two options.
Option 1:
You can save your user's current state by using the PSID and option picked by user.
Option 2:
You can design your payloads in a ways so that you can identify your options. For example, when you are sending A) 1, 2, 3, you would actually send A1, A2, A3 in your payload, and 1, 2, 3 as viewing texts.

Azizul Hakim
  • 154
  • 5