This n8n workflow processes incoming Telegram messages, differentiating between text and voice messages.
How it works:
- Message Trigger: The workflow initiates when a new message is received via the Telegram "Message Trigger" node.
- Switch Node: This node acts as a router. It examines the incoming message:
- If the message is
text
, it directs the flow along the "text" branch.
- If the message contains
voice
, it directs the flow along the "voice" branch.
- Get Audio File: For audio messages, this node downloads the audio file from Telegram.
- Transcribe Audio: The downloaded audio file is then sent to an "OpenAI Transcribe Recording" node, which uses OpenAI's
whisper-1
speech-to-text model to convert the audio into a text transcript.
- Send Transcription Message: Regardless of whether the original message was text or transcribed audio, the final text content is then passed to a "Send transcription message" node.
Setup Requirements:
- Telegram Bot Token: You will need a Telegram bot token configured in the "Message Trigger" node to receive messages.
- OpenAI API Key: An OpenAI API key is required for the "Transcribe audio" node to perform speech transcription.
Additional Notes:
This workflow provides a foundational step for building more complex AI-driven applications. The transcribed text or original text message can be easily piped into an AI agent (e.g., a large language model) for analysis, response generation, or interaction with other tools, extending the bot's capabilities beyond simple message reception and transcription.
👉 Need Help?
Feel free to contact us at 1 Node.
Get instant access to a library of free resources we created.