Extracting Phone Number

I am creating a bot for customer service and I will integrate it with WhatsApp and telegram. I was wondering if it is possible to all the bot to extract the number by itself? I do not want the user to input the number. If it is possible can you send a link or show me how?

For WhatApp, you can use the Twilio connector and the tracker.sender_id will be the user’s phone number. You can see an example of this in this repository for a COVID-19 chatbot.

For Telegram, I don’t believe this is possible as their API obfuscates this private information of the user, instead only providing the chat ID of the source message.

@kearnsw thank you for your reply, I will check it out and let you know. Also is it possible for me to ask the user to input their number the first time they enter the bot and then store and use it whenever I need it? If yes can you provide and example?

You could request this information in a form. Then as long as you include the following lines in your domain.yml file:


session_config:
  carry_over_slots_to_new_session: true

The slots will carry over to other sessions, e.g. phone_number in your case.

However, I typically handle that type of profile storage with an external database. In that scenario, you would use the same form to collect the information, but on submit you push that information to an external database. Then you’d add a custom action to the beginning of your stories that pulls the user profile and uses it to set the slots in the tracker.

Depending on the complexity of your use case, you might want to take the second approach.

The plan is every time the user has an inquiry or want to activate for example a certain bundle, the bot asks the user to input the number and then activates the bundle. So I’ll try the second one and if I have anymore questions I’ll post that. Thank you so much for your help