Reply in the bot: how to reply to a specific message
- Set up “Reply to a message with ID” for a message from a bot →
- Set up “Reply to a message with ID” for a message from a user →
The “Reply to a message with ID” setting allows the bot to send a reply along with the original message.
The message from the bot will appear as if a chat participant selected the “Reply” option before sending the text or media file.
The bot can reply to both its own messages and those from users.
“Reply to a message with ID” is supported in the following components:
- Message
- Buttons
- Buttons with hints
- Buttons with hints for VKontakte
- Image
- Media Files
- Paid Media Files
- Gallery
- Video
- Geolocation
- Document
- Dynamic buttons with hints
- Navigation buttons for Telegram
- Audio
It works on Telegram.
This is how the reply message function will look like on Telegram:
Set up “Reply to a message with ID” for a message from a bot
In order for the bot to reply to its previous message, expand the message settings and copy the following template into the “Reply to a message with id” field {{lastMessageId}}
The setting should be filled in only in the message that should come as a response.
The “Reply to a message with ID” field will work with both the template for displaying the ID and the message ID as the written text.
To respond to any message from the bot, including the message that is not the last, first overwrite {{lastMessageId}} to a variable with a new name:
- Add Assign a variable right after the message that the bot will have to respond to.
- Come up with any name for the variable, for example, var
- Copy and paste the following template to the Variable value {{lastMessageId}}
- Next, add a component that the bot will send as a response to one of the previous messages, fill it out and expand the settings of this component.
- Find the “Reply to a message with ID” setting and output the overwritten variable, in our case it is {{var}} in curly brackets.
Set up “Reply to a message with ID” for a message from a user
To respond to the last message from the user, copy the following template into the “Reply to a message with ID” field: {{lastUpdate.parsed.messageId}}
The setting should be filled in only in the message that should come as a response after the message from the user.
This means that you can fill in the «Reply to a message with ID» field in the component that comes after User Input or Fork that accepted what the user sent to the bot.
The “Reply to a message with ID” field will work with both the template for displaying the ID and the message ID as the written text.
To reply to any message from the user, including a message that is not the last, first overwrite {{lastUpdate.parsed.messageId}} to a variable with a new name:
- Create a screen where the user can send a message to the bot. There may be Message or other visible to users component on the screen, followed by User Input or Fork.
- Add Assign a variable right after User Input or Fork that accepts the message.
- Come up with any name for the variable, for example, var
- Copy the following template to Variable value {{lastUpdate.parsed.messageId}}
- Below, add the component that the bot will send as a response to a user message, fill it out and expand the settings of this component.
- Find the “Reply to a message with id” setting and output the overwritten variable, in our case it is {{var}} in curly brackets.