Action: Wait for answer¶
With this action, the bot waits for a message from the user before continuing with the next actions. You can validate the user's input and configure options to cancel the wait, display error messages, or redirect them elsewhere.
What can you do with this action?¶
- Validate messages: Ensure that the user sends text, numbers, multimedia, or specific information using predefined validations or regular expressions.
- Cancel the wait: Allow the user to cancel the action with a specific message, such as a command or keyword, preventing further actions from executing.
- Use submitted data: The content sent by the user will be available for use in subsequent actions.
How to configure the action?¶
1. Create the action¶
- Go to your bot and click
🛠 Edit
to enter edit mode. - Select the button or command where you want to add the action, or create a new one.
- Click
Actions 🌟
→🎯 New action
→⏳ Wait for answer
. - Click
Configure 🛠
to set up this action.
2. Configure the options¶
➡️ Validation
¶
Define what the user must send. You can also use regular expressions for advanced validations.
Predefined validation types:
-
Text
-
Number
-
Email
-
URL
-
Video
-
Photo
-
Audio
-
Document
-
Animation
-
Contact
-
Forwarded
-
Location
➡️ Error message
(optional)¶
Text that will be sent if the user does not meet the validation criteria. Allows retries.
➡️ Cancellation texts
(optional)¶
Keywords that allow the user to cancel the wait (e.g., Cancel
, Exit
). By default, /start
cancels any bot wait.
➡️ Show message on cancel
(optional)¶
Message that will be sent to the user if they cancel the wait.
➡️ Press button on cancel
(optional)¶
Define a button or command to redirect the user upon cancellation. Example: /start
3. Activate the action¶
Click ✅ Activate
to enable this action and make it functional.
What does the action return through its ID?¶
The action returns information about the message sent by the user, and the user who sent the message.
Format to obtain information
#ActionID.data#
- ActionID: The action ID of
Wait for answer
(this action). - data: The information you want to obtain (example,
text
).
1. General data from the user’s message¶
text
: The text content sent by the user. Example:Hello, I want more information.
file_type
: Type of file sent (e.g.,photo
,video
,document
, etc.).file_id
: Unique ID of the sent multimedia file, useful for reuse in other actions.
2. User data¶
id
: Unique user ID in Telegram. Example:123456789
.first_name
: User’s first name. Example:John
.last_name
: User’s last name (if available). Example:Doe
.username
: Telegram username (without@
). Example:john_doe
.language_code
: User’s language in ISO 639-1 format. Example:en
.is_forward
:True
if the message is forwarded; otherwise,False
.is_premium
:True
if the user has a Telegram Premium subscription; otherwise,False
.contact
: Contact information shared by the user (if provided).location
: Coordinates of the user’s shared location (if provided).
3. Data if the message was forwarded (is_forward
is True
)¶
forward.id
: Unique ID of the chat where the forwarded message originated.forward.title
: Name of the channel or group where the forwarded message came from.forward.first_name
: First name of the original sender.forward.last_name
: Last name of the original sender.forward.username
: Username of the original sender (without@
).forward.is_bot
:True
if the original sender is a bot; otherwise,False
.forward.is_premium
:True
if the original sender has Telegram Premium; otherwise,False
.
Practical example: Requesting an email¶
In this example, the bot guides the user to provide their email. The bot validates the email format, thanks the user, and sends the email to the administrator.
1. Create a new button¶
- Enter edit mode by clicking
🛠 Edit
in your bot. - Click
✳️ New button | command
. - Enter the button name, e.g.,
Send email
. - Click
Actions 🌟
to configure the button's actions.
2. Add the necessary actions¶
a) Action 1: Send message¶
The bot asks the user to provide their email.
- Click
🎯 New action
→✉️ Send message
. -
Click
Configure 🛠
→💬 Set message 💬
and enter:Hello {first_name}, please send your email to continue. If you wish to cancel, type /cancel
-
Go back to the actions menu and click
✅ Activate
.
b) Action 2: Wait for answer¶
The bot waits for the email and validates it.
- Click
🎯 New action
→⏳ Wait for answer
. -
Click
Configure 🛠
and adjust the following settings:- Validation: Select
email
to ensure the user sends a valid email. -
Error message: Enter a message for invalid emails. Example:
The email you sent is not valid. Please try again.
-
Cancellation texts: Enter
/cancel
to allow the user to cancel. - Show message on cancel: Enter a message for cancellations. Example:
Operation canceled. If you need help, feel free to contact us.
- Validation: Select
-
Go back to the actions menu and click
✅ Activate
.
c) Action 3: Send message (to the user)¶
The bot confirms the email was received successfully.
- Click
🎯 New action
→✉️ Send message
. -
Click
Configure 🛠
→💬 Set message 💬
and enter:Thank you for providing your email.
-
Go back to the actions menu and click
✅ Activate
.
d) Action 4: Send message (to the admin)¶
The bot sends the received email to the administrator.
- Copy the Action ID of
Wait for answer
(action 2). - Click
🎯 New action
→✉️ Send message
. -
Click
Configure 🛠
→💬 Set message 💬
and enter:📧 New email received: Email: {#ActionID.text#} User: {#ActionID.first_name#}
Replace
ActionID
with the action ID fromWait for answer
that you copied. -
Click
👤 Send to someone else 👤
and enter your@username
or your Telegram user ID. - Go back to the actions menu and click
✅ Activate
.
Final result¶
Your action flow should look like this:
- Send message: The bot asks for an email.
- Wait for answer: The bot validates the email.
- Send message: The bot thanks the user.
- Send message: The bot notifies the admin.