Ai Agent can not get text from last node

I have a strange question. I’m working on a small LINE + AI agent bot. So far, feeding text and images to the AI works fine. However, when voice input comes in, I use Google Speech-to-Text to convert it into text, but the resulting text somehow doesn’t get picked up by the AI.
Strangely though, if I click in and view the generated text, it displays correctly.

Here’s the ternary expression I’m using:

{{ 
  $json.body.events[0].message.type == "text" 
    ? $json.body.events[0].message.text 
    : ($json.body.events[0].message.type == "image" 
        ? "Please check my image" 
        : ($json.body.events[0].message.type == "audio" 
            ? $('AudioToText').item.json.results[0].alternatives[0].transcript 
            : "error"))
}}



Information on your n8n setup

  • n8n version: 1.88.0
  • Database (default: SQLite): PostgreSQL
  • n8n EXECUTIONS_PROCESS setting (default: own, main): Default
  • **Running n8n via (Docker, npm, n8n cloud, desktop app):**Docker on k8s
  • Operating system: k8s with ubuntu 22

You could just try reference each previous variable without making a conditional waterfall. That may help. I am unsure why you are encountering the issue tho.

But other two flow is workable

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.