I’m using a Chat block with RAG enabled. The debugger shows RAG is retrieving the correct results in line 7, but line 8 always shows ‘Sending resolved message: undefined’ regardless of what I put in the template field. I’ve tried {{rag_results}}, {{preprocessed_message}}, {{user_message}}, and leaving the field blank. All return undefined. What is the correct variable name for the Chat block RAG template field?
I have a Chat block with RAG (Message Processing = RAG) and a Dynamic Tool configured. Two related problems:
Problem 1 — User message not being passed to AI
When the Dynamic Tool is enabled, the debugger shows line 9 as:
Sending resolved message: " <tools> ### Tools and Functions..."
The user’s actual message text is completely missing. Only the tools injection appears. The AI receives no message content and responds as if the message was blank.
Problem 2 — RAG template variable always undefined
Regardless of what I put in the RAG template field, the content resolves to undefined. I have tried: {{user_message}}, {{last_message}}, {{rag_results}}, {{preprocessed_message}}, and leaving it blank. The RAG IS retrieving correct results (confirmed in debugger line 8) but they are not being passed to the AI.
What is the correct variable name for the RAG template field in a Chat block, and does adding a Dynamic Tool interfere with message passing? How should these be configured together correctly?
Hi @Neil,
Thanks for the post and welcome to the Community!
The variables you can use in the Chat block with RAG are {{queryResult}} for the retrieved results and {{originalMessage}} for the user’s message.
Here’s the default template you can adjust, but make sure to keep the original variable names:
<context>
{{queryResult}}
</context>
Use the context above to answer the following message:
<original_user_message>
{{originalMessage}}
</original_user_message>
This should fix both issues.
Thank you Alex!!
One more question:
I have RAG configured at the Model Settings level and Message Processing set to No Processing in the Chat block — should I change Message Processing to RAG and add this template there, or should I apply this template somewhere in the Model Settings RAG configuration?
Hi @Neil,
If you’d like the Chat to use RAG when answering user questions, please take the steps below:
- Set Strategy in the End block to RAG
- Select your Data Source