edit_message
Modify existing Telegram messages by updating text content with support for HTML or Markdown formatting, using the message ID for precise editing.
Instructions
Edit an existing message
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| message_id | Yes | Message ID to edit | |
| parse_mode | No | Parse mode for new text | |
| text | Yes | New message text |
Input Schema (JSON Schema)
{
"properties": {
"message_id": {
"description": "Message ID to edit",
"type": "number"
},
"parse_mode": {
"description": "Parse mode for new text",
"enum": [
"HTML",
"Markdown",
"MarkdownV2"
],
"type": "string"
},
"text": {
"description": "New message text",
"type": "string"
}
},
"required": [
"message_id",
"text"
],
"type": "object"
}
Implementation Reference
- src/index.ts:423-444 (handler)The switch case that handles execution of the 'edit_message' tool. It destructures arguments, calls TelegramBot's editMessageText method with chat_id (CHANNEL_ID), message_id, text, and parse_mode, then returns a formatted success response.case 'edit_message': { const { message_id, text, parse_mode = 'HTML' } = args as { message_id: number; text: string; parse_mode?: string; }; const result = await bot.editMessageText(text, { chat_id: CHANNEL_ID, message_id, parse_mode: parse_mode as any, }); return { content: [ { type: 'text', text: `โ Message edited successfully!\n\n๐ฑ Channel: ${CHANNEL_ID}\n๐ Message ID: ${message_id}\n๐ New Text: ${text}`, }, ], }; }
- src/index.ts:151-173 (registration)The tool registration entry in the ListToolsRequestSchema response array, defining name, description, and inputSchema for 'edit_message'.{ name: 'edit_message', description: 'Edit an existing message', inputSchema: { type: 'object', properties: { message_id: { type: 'number', description: 'ID of the message to edit', }, text: { type: 'string', description: 'New message text', }, parse_mode: { type: 'string', enum: ['HTML', 'Markdown'], description: 'Parse mode for the message', }, }, required: ['message_id', 'text'], }, },
- src/index.ts:154-172 (schema)The input schema definition for the 'edit_message' tool, specifying required message_id and text, optional parse_mode.inputSchema: { type: 'object', properties: { message_id: { type: 'number', description: 'ID of the message to edit', }, text: { type: 'string', description: 'New message text', }, parse_mode: { type: 'string', enum: ['HTML', 'Markdown'], description: 'Parse mode for the message', }, }, required: ['message_id', 'text'], },