Hi everbody. I want to learn how can I write the clients age. For example >18 and <70.And if age is more than 18 it must be OK. how can I set that telegram bot for clients input
There’s a few ways you could do this.
Give choices such as “Which bracket does your age fall into <18, 18 < > 70, < 70”. Then you can use the users answer to decide whether the user is in the right bracket and can move forward through the bot using filters.
Ask for the users age and then filter the next actions based on age is greater than 18 and age is less than 70.
Ask for the users date of birth and use the Date and Time Service to calculate the age. Again the next actions would need a filter based on age is greater than 18 and age is less than 70.
I hope this helps.
is there a template about it?
The first two options that Karen shared would be the easiest way to handle it. You can just ask for an age in a question and then use filters to control how the flow should progress.
First, you would need to format the date using a custom format from the supported list here. There’s an option to format into seconds by setting it as ‘X’. If you were using a Catch-all trigger it would look something like this:
Now we have today’s date and time converted into seconds we can do a calculation to work out the year value.
There are 86400 seconds in a day and 365 days in a year so the calculation would be:
You’d then repeat these two actions for the date of birth provided by the user.
Once that’s done you’ll have two calculation outputs that you need to subtract from each other to get the age, e.g:
Here’s an example flow showing how this works:
Once you have the age you can have a filter setup to check whether it is greater than or equal to 18 to know if they’re of the right age.
Hope that helps! Please let me know if you have any questions.
is is working thank u lottt