Input types problem

(Govher Abbas Zade) #1

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

0 Likes

(Karen Barker) #2

Hi Govher,

There’s a few ways you could do this.

  1. 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.

  2. Ask for the users age and then filter the next actions based on age is greater than 18 and age is less than 70.

  3. 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. :slight_smile:

1 Like

(Govher Abbas Zade) #3

is there a template about it?

0 Likes

(Daniel Beckett) #4

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.

For the third option you can calculate a person’s age by using a combination of the Date & Time Service and the Number service.

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:

e1b2c149fbb23fed5fd602e2bfc16c82.png

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:
{{format_date_time_received.date}}/86400/365

ae19da3f14a000cd0db2bf03bb16f1ae.png

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:
{{calculate_time_received_into_days.result}}-{{calculate_dob_into_days.result}}

5230c8de970b58afc6f8f5bbbe40a457.png

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.:slightly_smiling_face:

Thanks,
Dan

1 Like

(Govher Abbas Zade) #6

is is working thank u lottt

0 Likes