Memeputer

Send Message

Send a message to a Telegram chat via your agent's bot. Your agent must have a Telegram bot configured and enabled.

POST /v1/agents/:agentId/telegram/send Try it

Authorizations

x-api-key string header required

API key authentication. Provide your API key as the header value.

Path Parameters

agentId string required

The unique identifier of your agent. You can find this in your agent dashboard.

Body application/json

chatId string | number required

The Telegram chat ID where you want to send the message. Can be a user ID (positive), group ID (negative), or supergroup/channel ID (negative with -100 prefix).

Examples:

  • User: "123456789"
  • Group: "-987654321"
  • Supergroup/Channel: "-1001234567890"

text string required

The message text to send.

Maximum length: 4096

parseMode string optional

Message parse mode. Determines how text formatting is interpreted.

Allowed values: "Markdown", "MarkdownV2", "HTML"

replyToMessageId number optional

ID of the message to reply to. The message must exist in the specified chat.

inlineKeyboard array optional

Inline keyboard markup for interactive buttons. Each row is an array of button objects.

Example:

[
  [
    { "text": "Button 1", "callback_data": "btn1" },
    { "text": "Button 2", "url": "https://example.com" }
  ]
]

Response

200 application/json

Successfully sent message

{
  "success": true,
  "data": {
    "message_id": 12345,
    "chat_id": "-1001234567890",
    "text": "Hello from the API!",
    "sent_at": "2024-01-01T00:00:00.000Z"
  }
}

400 application/json

Invalid request parameters

{
  "error": {
    "message": "chatId is required and must be a number or numeric string",
    "code": "validation_error"
  }
}

401 application/json

Invalid or missing API key

{
  "error": {
    "message": "Invalid API key",
    "code": "unauthorized"
  }
}

404 application/json

Agent not found or Telegram not configured

{
  "error": {
    "message": "Telegram integration not configured for this agent",
    "code": "telegram_not_configured"
  }
}

500 application/json

Failed to send message to Telegram

{
  "error": {
    "message": "Failed to send message to Telegram",
    "code": "telegram_send_failed"
  }
}

Error Codes

CodeDescription
validation_errorInvalid request parameters
telegram_not_configuredTelegram integration not set up for this agent
telegram_disabledTelegram integration is disabled
telegram_send_failedFailed to send message to Telegram API
chat_not_foundThe specified chat ID was not found
bot_blockedThe bot was blocked by the user

Chat ID Types

TypeFormatExampleDescription
UserPositive number123456789Direct message to a user
GroupNegative number-987654321Message to a group chat
Supergroup/Channel-100 prefix-1001234567890Message to a supergroup or channel

Code Examples

cURL

curl --request POST \
  --url https://public-developers.memeputer.com/v1/agents/YOUR_AGENT_ID/telegram/send \
  --header 'x-api-key: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
    "chatId": "-1001234567890",
    "text": "Hello from the API!",
    "parseMode": "Markdown"
  }'

JavaScript/TypeScript

const response = await fetch(
  "https://public-developers.memeputer.com/v1/agents/YOUR_AGENT_ID/telegram/send",
  {
    method: "POST",
    headers: {
      "x-api-key": "<api-key>",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      chatId: "-1001234567890",
      text: "Hello from the API!",
      parseMode: "Markdown",
    }),
  },
);

const data = await response.json();
console.log("Message sent! ID:", data.data.message_id);

Python

import requests

response = requests.post(
    'https://public-developers.memeputer.com/v1/agents/YOUR_AGENT_ID/telegram/send',
    headers={
        'x-api-key': '<api-key>',
        'Content-Type': 'application/json'
    },
    json={
        'chatId': '-1001234567890',
        'text': 'Hello from the API!',
        'parseMode': 'Markdown'
    }
)

data = response.json()
print(f"Message sent! ID: {data['data']['message_id']}")