Error in HAL 9001 Agent Node: "Cannot read properties of undefined (reading 'content')"

I’m building an AI automation workflow with n8n using the HAL 9001 agent node (from LangChain). The workflow receives a Telegram message, processes it, and passes it to the agent for delegation to sub-agents.

However, I’m encountering the following error:
Cannot read properties of undefined (reading ‘content’)

Workflow Overview:

  1. Input: Telegram message → Switch (handles text/audio/image)
  2. Set Message: Assigns userMessage, modal, and sessionId
  3. HAL 9001 Agent: Processes the input and delegates to supervisors (Productivity, Communication, etc.)

Error Details:

  • The error occurs in the HAL 9001 node.
  • The input to the agent is:

{
“userMessage”: “Hii”,
“modal”: “text”,
“sessionId”: “1761264379”
}

What I’ve Tried:

  • Checked the input data—confirmed userMessage exists but not content.
  • Looked at the HAL 9001 node’s system message, which includes:

{{ $json?.text || $json?.content || $json?.body?.message || $json?.message?.text || “” }}

  • Tried modifying the system message to include userMessage, but the error persists.

Questions:

  1. Should I modify the input to include a content field?
  2. Or should I adjust the HAL 9001 node’s prompt to use userMessage instead?
  3. Has anyone else faced this issue with the LangChain agent nodes?