AI Trainer: Telegram Message Send¶
This workflow delivers AI-generated content to Telegram users with intelligent format selection — sending either voice messages (using ElevenLabs or OpenAI text-to-speech) or plain text based on user preferences. It serves as a delivery endpoint for AI training systems that need to communicate with learners through Telegram.
Purpose¶
No business context provided yet — add a context.md to enrich this documentation.
This workflow appears to be part of an AI training or coaching system that delivers personalized content to users via Telegram. It intelligently chooses between voice and text delivery based on user preferences, making learning content more accessible and engaging.
How It Works¶
- Receives Input: Another workflow triggers this one with message content, voice preference, and target chat ID
- Format Decision: Checks if the user wants voice output or text-only delivery
- Voice Generation (if requested):
- Sets up ElevenLabs voice ID for text-to-speech conversion
- Attempts to generate audio using ElevenLabs API
- Falls back to OpenAI's text-to-speech if ElevenLabs fails
- Message Delivery: Sends either the generated audio file or plain text to the specified Telegram chat
- Confirmation: Returns success status to the calling workflow
Workflow Diagram¶
graph TD
A[When Executed by Another Workflow] --> B[If Voice Out]
B -->|Voice Requested| C[Voice ID]
B -->|Text Only| G[Telegram1 - Send Text]
C --> D[Generate voice 11labs]
D -->|Success| E[Telegram - Send Audio]
D -->|Error| F[Generate voice openai backup]
F --> E
E --> H[Output]
G --> H
Trigger¶
Execute Workflow Trigger: This workflow is designed to be called by other workflows, not triggered directly. It expects three input parameters:
- output (string): The message content to send
- is_voice (boolean): Whether to send as voice message or text
- chat_id (string): The Telegram chat ID to send the message to
Nodes Used¶
| Node Type | Node Name | Purpose |
|---|---|---|
| Execute Workflow Trigger | When Executed by Another Workflow | Receives input from calling workflow |
| If | If Voice Out | Determines delivery format based on user preference |
| Set | Voice ID | Configures ElevenLabs voice ID for audio generation |
| HTTP Request | Generate voice 11labs | Converts text to speech using ElevenLabs API |
| OpenAI | Generate voice openai (backup) | Backup text-to-speech service |
| Telegram | Telegram | Sends audio messages to Telegram chat |
| Telegram | Telegram1 | Sends text messages to Telegram chat |
| Set | Output | Returns execution status to calling workflow |
External Services & Credentials Required¶
ElevenLabs API¶
- Credential:
Elevenlabs (Johns Key)(HTTP Header Auth) - Purpose: Primary text-to-speech service
- Required: API key for ElevenLabs service
OpenAI API¶
- Credential:
OpenAi account - Purpose: Backup text-to-speech service
- Required: OpenAI API key with audio generation access
Telegram Bot API¶
- Credential:
Telegram account 2 - Purpose: Message delivery to Telegram chats
- Required: Telegram bot token
Environment Variables¶
No environment variables are used in this workflow. All configuration is handled through n8n credentials and hardcoded values.
Data Flow¶
Input¶
1 2 3 4 5 | |
Output¶
1 2 3 | |
The workflow returns a boolean indicating successful message delivery.
Error Handling¶
- ElevenLabs Fallback: If ElevenLabs voice generation fails, the workflow automatically falls back to OpenAI's text-to-speech service
- Continue on Error: The ElevenLabs node is configured to continue execution even if it encounters errors, ensuring the backup system activates
Known Limitations¶
- Voice ID is hardcoded (
Z8dg0fyk7p6js7cQ7lgi) and cannot be dynamically changed per user - No retry mechanism if both voice generation services fail
- No validation of input parameters before processing
- Audio files are always named "audio.mp3" regardless of content
Related Workflows¶
This workflow is designed to be called by other AI training workflows that generate content and need to deliver it to users. Look for workflows that use "Execute Workflow" nodes targeting this workflow.
Setup Instructions¶
-
Import Workflow: Import the JSON into your n8n instance
-
Configure Credentials:
- Set up ElevenLabs HTTP Header Auth credential with your API key
- Configure OpenAI API credential for backup voice generation
- Add Telegram Bot API credential with your bot token
-
Test Voice Generation:
- Verify ElevenLabs API access and voice ID validity
- Test OpenAI text-to-speech as backup option
-
Telegram Setup:
- Ensure your Telegram bot has permission to send messages and audio files
- Test with a known chat ID to verify delivery
-
Integration:
- Update calling workflows to use this workflow's ID
- Ensure input parameters match the expected format
-
Customize Voice:
- Replace the hardcoded voice ID in the "Voice ID" node with your preferred ElevenLabs voice
- Adjust voice settings (stability, similarity_boost) as needed