FredrikOseberg / react-chatbot-kit

MIT License
299 stars 139 forks source link

how to manage an order of messages and handle it in messageParser, parse method? #49

Closed aman54kumar closed 3 years ago

aman54kumar commented 3 years ago

I have a situation where it's a questionnaire asked by the bot and the user replies (not necessarily from chosen options but can be typed by the user as well). So, for example, multiple user replies can be of the format of national ID.
I need to know which step of the chat is currently going on. So I can differentiate between question 2 and question 7 asking for the national ID of the person and the national ID of his spouse. (Just a scenario, but I have a similar situation). And this information is needed inside the parse() method so, I can trigger the correct method from ActionProvider class.

Any idea how to approach this? I am stuck here but altogether, thanks for a great library. and the documentation/videos you made.

FredrikOseberg commented 3 years ago

You could set a stepId in the state object in the configuration and update it according to the trigger in the actionprovider? Does that help your use case?

aman54kumar commented 3 years ago

yes, it worked. It is working seamlessly. Also found the way to access state in ActionProvider using setState from one of the issues you answered earlier. I have been able to get over my problems and continuing with the development. Tusen takk :)