send_photo
Send photos to Telegram channels using a URL or file path, with optional caption formatting in HTML or Markdown for automated bot messaging.
Instructions
Send a photo to the Telegram channel
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| caption | No | Photo caption | |
| parse_mode | No | Parse mode for caption | |
| photo | Yes | Photo URL or file path |
Input Schema (JSON Schema)
{
"properties": {
"caption": {
"description": "Photo caption",
"type": "string"
},
"parse_mode": {
"description": "Parse mode for caption",
"enum": [
"HTML",
"Markdown",
"MarkdownV2"
],
"type": "string"
},
"photo": {
"description": "Photo URL or file path",
"type": "string"
}
},
"required": [
"photo"
],
"type": "object"
}
Implementation Reference
- src/index.ts:354-374 (handler)The handler function for the 'send_photo' tool. It extracts photo_url, caption, and parse_mode from arguments, sends the photo to the Telegram channel using bot.sendPhoto, and returns a success message with details.case 'send_photo': { const { photo_url, caption, parse_mode = 'HTML' } = args as { photo_url: string; caption?: string; parse_mode?: string; }; const result = await bot.sendPhoto(CHANNEL_ID, photo_url, { caption, parse_mode: parse_mode as any, }); return { content: [ { type: 'text', text: `โ Photo sent successfully!\n\n๐ฑ Channel: ${CHANNEL_ID}\n๐ Message ID: ${result.message_id}\n๐ท Photo: ${result.photo?.[0]?.file_id}\n๐ Caption: ${caption || 'No caption'}`, }, ], }; }
- src/index.ts:80-102 (registration)Registers the 'send_photo' tool in the list of available tools, including its description and input schema definition.{ name: 'send_photo', description: 'Send a photo to the Telegram channel', inputSchema: { type: 'object', properties: { photo_url: { type: 'string', description: 'URL of the photo to send', }, caption: { type: 'string', description: 'Photo caption', }, parse_mode: { type: 'string', enum: ['HTML', 'Markdown'], description: 'Parse mode for the caption', }, }, required: ['photo_url'], }, },
- src/index.ts:83-101 (schema)Defines the input schema for the 'send_photo' tool, specifying photo_url as required, and optional caption and parse_mode.inputSchema: { type: 'object', properties: { photo_url: { type: 'string', description: 'URL of the photo to send', }, caption: { type: 'string', description: 'Photo caption', }, parse_mode: { type: 'string', enum: ['HTML', 'Markdown'], description: 'Parse mode for the caption', }, }, required: ['photo_url'], },