Telegram Send Message

Send a message to a Telegram user via Flask API

Overview

This node sends a message to a Telegram user by making an HTTP POST request to a specified Flask API endpoint. It is useful when you want to integrate Telegram messaging into your workflows without directly using the Telegram Bot API, instead relying on a custom backend service that handles the actual sending.

Typical use cases include:

  • Sending notifications or alerts to specific Telegram users from automated workflows.
  • Integrating Telegram messaging in systems where a custom API manages message delivery.
  • Using a secure token-based authentication mechanism to control access to the messaging API.

For example, you can configure this node to send a personalized message to a Telegram username by specifying the username, message content, and the URL of your Flask API that handles sending messages.

Properties

Name Meaning
Username The Telegram username of the recipient to whom the message will be sent.
Message The text content of the message to send to the specified Telegram user.
API URL The base URL of the Flask API endpoint responsible for sending the message.
Auth Token A secret token used for authenticating the request with the Flask API (kept confidential).

Output

The node outputs an array with one object per input item processed. Each output object contains a json field with the following structure:

  • success: A boolean indicating whether the message was sent successfully.
  • response: If successful, contains the data returned by the Flask API.
  • error: If unsuccessful, contains the error message or the error response data from the API.

No binary data is produced by this node.

Example output JSON for a successful request:

{
  "success": true,
  "response": {
    /* API response data */
  }
}

Example output JSON for a failed request:

{
  "success": false,
  "error": "Error message or API error details"
}

Dependencies

  • Requires access to a Flask API endpoint capable of sending Telegram messages.
  • The API must accept POST requests at the URL formed by concatenating the provided API URL and the Telegram username.
  • The API expects a JSON body with a message field.
  • Authentication is done via a custom header "X-Zuper-Auth" containing the provided auth token.
  • The node depends on the axios library for HTTP requests (bundled internally).

Troubleshooting

  • Common issues:

    • Incorrect API URL or endpoint path may cause connection errors or 404 responses.
    • Invalid or missing auth token will likely result in authentication errors from the API.
    • Network connectivity problems between n8n and the Flask API server.
    • The Telegram username might be invalid or not recognized by the backend service.
  • Error messages:

    • If the API returns an error response, it will be included in the error field of the output.
    • If the request fails due to network or other axios-related errors, the error message will be shown.
  • Resolutions:

    • Verify the API URL and ensure the Flask service is running and accessible.
    • Confirm the auth token is correct and has necessary permissions.
    • Check network/firewall settings to allow outbound requests.
    • Validate the Telegram username format and existence.

Links and References

  • Axios GitHub Repository – HTTP client used internally.
  • Telegram Usernames – Information about Telegram usernames.
  • Custom Flask API documentation (not provided here) should be consulted for exact API usage and authentication details.

Discussion