Telegram bots do not have access to personal data, and the number is not stored in the {clientPhone} variable. Read more about variables in the article System variables. You can get a phone number in Telegram only with the client's consent using the Share number function. To do this, follow the steps below:
- Go to the Bots section of personal account.
- Open the desired script in the editor. If you don't have a script, create a new one.
- Select the Question block to which you want to add an action.
- Click on the Actions tab.
- Add the Request contact action.
- Specify a caption for the button.
The Question block must not be empty, otherwise the button will not be displayed.
- Drag the arrow from the Question block to the block of interest and click on it.
- Action type: Number.
- Number: Between.
- Enter the mask of the phone number of the selected country. For example, for USA, this is a number from (000) 000-0000 to (999) 999-9999.
- Complete the Quick answer field. The text in this field should be the same as in step 6.
- Declare the name of a new variable in the Save answer field where the received number will be saved.
- Save the script.
Now, when a customer writes to the bot in Telegram, a Share Number button will appear. The client will be able to click on the button and agree to send their number, or enter an arbitrary number corresponding to the phone number mask of the selected country.