Prompt
The Prompt component lets you build a message that will be sent to a language model.
You write a template that contains placeholders (like {name}
or {order_id}
).
The component then replaces those placeholders with values that come from other parts of your workflow, producing a complete prompt ready for the AI.
How it Works
The component works entirely inside Nappai.
When you drop it into a flow, you type a template with variables wrapped in {}
.
If you turn on Mapping Mode, each variable can receive a value in one of three ways:
- Fixed – you type a constant value.
- Mapped – you connect an output from another component (e.g., a text input or a data parser).
- Javascript – you write a small script that computes the value at run time.
Once all variables have values, the component stitches the pieces together into a single text string.
That string is stored in the component’s status (so you can see it quickly) and is sent out as a Message object named Prompt Message.
Inputs
Mapping Mode
This component has a special mode called “Mapping Mode.”
When you enable this mode using the toggle switch, an additional input called “Mapping Data” is activated, and each input field offers you three different ways to provide data:
- Fixed: You type the value directly into the field.
- Mapped: You connect the output of another component to use its result as the value.
- Javascript: You write Javascript code to dynamically calculate the value.
This flexibility allows you to create more dynamic and connected workflows.
Input Fields
- Template: Enter your prompt template with dynamic variables using single curly braces
{variable}
. Example:Hello {name}, your order {order_id} is ready!
Variables will be automatically detected and become available as input fields.
Outputs
- Prompt Message: A Message object that contains the fully‑stitched prompt text. This output can be fed into any component that expects a text prompt, such as OpenAIModel, LanggraphReactAgent, or a chat input.
Usage Example
- Add the Prompt component to your flow.
- Write a template such as
Hi {user_name}, you have {message_count} new messages.
- Enable Mapping Mode.
- Map
user_name
to a TextInput component that collects the user’s name. - Map
message_count
to the output of a ParseData component that counts unread messages. - Connect the Prompt Message output to an OpenAIModel component to generate a response.
When you run the flow, the Prompt component will replace {user_name}
and {message_count}
with the supplied values and send the final prompt to the AI.
Important Notes
🔒 Avoid Untrusted User Input in Templates 🟡
If the template includes data from external or untrusted sources, be careful to sanitize it. Unsanitized input could influence the prompt in unintended ways or cause misbehavior of downstream models.
⚠️ Missing Variables Cause Errors 🟡
If the template references variables that are not supplied by connected components, the Prompt component will fail to build and show an error. Make sure every placeholder has a matching input.
📋 Enable Mapping Mode for Variable Inputs 🟢
The Prompt component relies on mapping mode to receive variable values from other components. Ensure that mapping mode is turned on and that each variable is properly connected.
💡 Use Clear and Consistent Variable Names 🟢
Choose descriptive names for variables and keep the template concise. This makes it easier to map inputs and reduces the chance of mismatches or confusion during debugging.
⚙️ Template Syntax Must Use Double Curly Braces 🟢
Placeholders in the template should be wrapped in double curly braces (e.g., {{user_name}}
). Incorrect syntax will cause the template to fail validation and result in an error.
ℹ️ Component Status Shows Generated Prompt 🟢
After building the prompt, the component’s status field displays the final prompt text. This can help you quickly verify the output without opening the full Message output.
Tips and Best Practices
- Keep your templates short and focused; long prompts can confuse the AI and make debugging harder.
- Test each variable individually by connecting a fixed value before wiring up dynamic sources.
- Use descriptive variable names so you can easily trace them in the flow designer.
- Sanitize any user‑supplied data before inserting it into a prompt to avoid injection attacks.
Security Considerations
Always review the content of templates that are built from user input.
Unvalidated or malicious text can be injected into the prompt, leading to unexpected model behavior or disclosure of sensitive data. Use sanitization libraries or simple string checks to strip disallowed characters and keep the prompt clean.