How I Fixed Expression Parsing for Dynamic LLM Prompts in n8n

Hi everyone! :waving_hand:

I wanted to share a problem I faced while working on an automation using n8n with an external LLaMA 3 model API, and how I solved it. Posting here in case it helps others in the community! :raising_hands:

:puzzle_piece: Goal:

I was building a workflow where:

  • I extract emailBody from incoming JSON (Set node),
  • Then I send a prompt to an LLM (via HTTP Request node),
  • The prompt should summarize the content in Bengali (বাংলা) and determine if the news is Bullish, Bearish, or Neutral.

When I used the following in Fixed mode:

{
  "model": "llama3",
  "prompt": "নিউজ: " + $json["emailBody"] + " এর সারাংশ বাংলায় ৪ লাইনে লিখুন, এবং নিউজটি বুলিশ, বেয়ারিশ বা নিউট্রাল কিনা চিহ্নিত করুন।",
  "stream": false
}

It resulted in an error or the model replied with:

model": “llama3”,
“created_at”: “2025-07-26T03:10:16.46672752Z”,
“response”: “I’d be happy to help you with that. Please provide the JSON data for {"emailBody"} and I’ll translate it into a 4-line summary in Bangla.\n\nPlease note that I’ll do my best to provide an objective summary, neither biased nor sensationalized.”,
“done”: true,

Clearly, the expression wasn’t being evaluated — instead it was sent as a string literal.