How WhatsApp bot works - part 6
In order to make the bot’s flow more generic, it is a good strategy to pass parameters into the bot’s flow.
You pass parameters into the bot’s flow by using JSON, and then in the flow, you can use them to make decisions, display dynamic messages, etc…
One of the things you can do with parameters in the flow is to display a session message or a template message according to the state of the 24 window that the phone number (of the user you are sending the message to) is in.
You pass a status parameter, and it contains, for example, 1 for session message and 2 for template message.
You also pass the TWO types of messages as parameters, into the bot’s flow.
The first message in the bot’s flow will contain code that will check the status parameter, and if it will be equal to 1 the session message parameter’s content will be displayed, and the same thing for the template message.
This way, you keep the rules of WhatsApp, to send a :
Session message – when the last interaction with the destination number was LESS than 24 hours ago
Template message – when the last interaction with the destination number was MORE than 24 hours ago.