I'm building a Telegram chatbot in n8n that uses OpenAI to process both text and voice messages. Text messages work fine, but for voice messages, the AI Agent node throws a "No prompt specified" error even though the transcription exists


Hello,

I’m currently developing a conversational agent on n8n, connected to Telegram, with the goal of receiving messages (text or voice) and automatically replying via the AI Agent node.


:white_check_mark: What works:

When I send a text message via Telegram:

  • The message is successfully captured,
  • It is passed to the AI Agent node,
  • The prompt is recognized ({{ $json.message.text }}), and the response is correctly sent back via Telegram.

:x: Issue encountered:

When I send a voice message, I get the following error from the AI Agent node:

Problem in node 'AI Agent'
No prompt specified

:mag: Details:

  • The voice message is successfully downloaded using Telegram -> Get File.
  • The transcription is correctly performed using OpenAI - Transcribe Recording, and the text field is present in the output.
  • I use {{ $json.text }} in the Prompt (User Message) field of the AI Agent node.
  • However, the "No prompt specified" error appears only with voice messages.
  • The text field is clearly visible in the output JSON of the previous node.

:wrench: What I’ve tried:

  • Added a Switch to handle text and voice messages separately.
  • Used {{ $json.text }} for voice and {{ $json.message.text }} for text.
  • Added a Set node to unify both into a common field like prompt = {{ $json.text }}.
  • Set "language": "fr" in the transcription node to force French.

:bulb: What I need:

I want the AI Agent node to dynamically handle either case:

  • Use message.text when the message is a text,
  • Use text (transcription result) when it’s a voice message,
  • And generate a response in both scenarios without triggering the "No prompt specified" error.

Any suggestions or working setups are welcome. Thanks in advance!

Preformatted text

Not clean, but probably works

connect both node, json.text and json.message.text

then in your ai prompt field. use like :

// your input here
{{  $json.text ?? json.message.text }}