Action: delete messageΒΆ
This action allows you to delete messages previously sent using the send message or wait for answer actions. You can specify one or multiple messages to delete them in a single step.
What can you do with this action?ΒΆ
- Delete individual or multiple messages.
How to create and configure the action?ΒΆ
1. Create the actionΒΆ
- Go to your bot and tap
π Editto enter edit mode. - Select the button or command where you want to add the action, or create a new one.
- Click
Actions πβπ― New actionββ Delete message. - Click
Configure πto set up this action.
2. Configure the messages to deleteΒΆ
Click π Set message to delete π and specify the messages to delete, separated by commas, using the following methods:
#ActionID#: ID of the action of anotherSend messageorWait for answeraction within the same button or command.message_id: The ID of a message generated by Telegram, previously stored in a variable or entered directly.
Some examples
-
Using
#ActionID#and#ActionID.message_id#:#ActionID#, #ActionID2.message_id# -
Using
message_identered directly:12345, 67890 -
Using
message_idstored in a numeric variable calledmessage_id:{message_id} -
To delete multiple messages, separate them with commas:
#ActionID#, #ActionID2.message_id#, 56789
3. Activate the actionΒΆ
Click β
Activate to enable the action.
What does the action return through its ID?ΒΆ
This action does not return any value.
Practical example: How to delete a messageΒΆ
In this example, the bot will send an initial message, ask the user to type something, and then delete both the initial message and the user's response.
1. Create a new buttonΒΆ
- Enter edit mode by clicking
π Editin your bot. - Click
β³οΈ New button | command. - Enter the button name.
- Click
Actions πto configure the actions for this button.
2. Add the necessary actionsΒΆ
a) Action 1: Send messageΒΆ
- Click
π― New actionand selectβοΈ Send message. -
Click
Configure πβπ¬ Set message π¬and set an initial message. Example:Hello {first_name}, type a message: -
Return to the actions menu and click
β Activateto enable this action.
b) Action 2: Wait for answerΒΆ
- Click
π― New actionand selectβ³ Wait for answer. - No configuration required, click
β Activateto enable this action.
c) Action 3: Delete messageΒΆ
- Copy the ID of the action from both previously created actions (
Send messageandWait for answer). - Click
π― New actionand selectβ Delete message. - Click
Configure π. -
Click
π Set messages to delete πand enter the IDs of both actions, separated by a comma. Example:#701ka#, #SNxTR# -
Return to the actions menu and click
β Activateto enable this action.
Final resultΒΆ
Your action flow should look like this:
- Send message: The bot sends the initial message.
- Wait for answer: The bot waits for the user's input.
- Delete message: Both messages (the initial and the user's response) are deleted.
