Daemon
How to invoke an agent from Salesforce Flows and automated processes.
Overview
The Daemon lets you call a Flourish agent directly from a Salesforce Flow — without a user or chat interface involved.
The agent receives a message, reasons over it (using whatever tools and trusted resources are configured on its deployed version), and returns a text response. The Flow waits for the result before continuing.
Two modes are supported:
- Stateless — each call is independent. No conversation history is retained between invocations.
- Stateful — the agent maintains a conversation across multiple calls using a Conversation ID. Use this for multi-turn automations where the agent needs to remember what was said previously.
Note: The Daemon has a 120-second timeout. For tasks that may take longer, consider breaking the work into smaller steps.
Adding It to a Flow
In Flow Builder, add an Action element and search for:
Invoke Agent (Daemon)
It appears under the Flourish Agent Platform category.
Inputs
| Input | Required | Description |
|---|---|---|
| Agent External Id | ✅ | The Agent ID of the agent to invoke. Copy this from the Agent Builder using the Copy Agent ID button. |
| Message | ✅ | The message to send to the agent — the equivalent of what a user would type in chat. |
| Stateful | — | Set to true to start or continue a persistent conversation. Defaults to false. |
| Conversation Id | — | Required when resuming a stateful conversation. Pass the Conversation ID returned by a previous Daemon call. Leave blank to start a new conversation. |
| Host Context JSON | — | An optional JSON string of additional context passed to the agent at runtime. The agent can reference these values in its reasoning. |
Outputs
| Output | Description |
|---|---|
| Response | The agent's text response. |
| Conversation Id | The conversation ID for stateful calls. Store this in a Flow variable if you need to resume the conversation later. |
Stateless vs. Stateful
Stateless (default)
Each invocation is completely independent. The agent has no memory of previous calls. Use this for one-shot tasks like summarizing a record, classifying text, or generating a draft email.
Leave Stateful unchecked (or set to false) and leave Conversation Id blank.
Stateful
The agent maintains conversation history across calls. The first call starts a new conversation and returns a Conversation ID. Pass that ID back on the next call, and the agent picks up where it left off.
First call: Set Stateful to true and leave Conversation Id blank. The output includes a new Conversation ID (e.g. conv-abc-123).
Subsequent calls: Set Stateful to true and pass the stored Conversation Id. The agent continues with full context from earlier turns.
Store the Conversation ID on a Salesforce record or in a Flow variable so it survives across separate Flow executions, batch jobs, or time-triggered automations.
Passing Host Context
The Host Context JSON input lets you pass structured data to the agent alongside the message. The agent receives this as additional context it can draw on when forming its response.
Any valid JSON string is accepted. For example, you could pass record data so the agent can reason about a specific Salesforce record:
{
"record_id": "0013X00000AbCdEF",
"account_name": "Acme Corp",
"annual_revenue": 5000000,
"owner": "Jane Smith"
}
In Flow, build this string using a Text Template or an Assignment element that concatenates field values into a JSON structure.
Example Flow Patterns
Summarize a Case on Close
Trigger a Flow when a Case is closed. Pass the case description and comments to the agent, then write the summary back to a custom field.
- Trigger: Case status changes to Closed.
- Get Records: Retrieve the case details.
- Action — Invoke Agent (Daemon): Send the case description and comments as the message.
- Update Records: Write the agent's response to a custom
AI_Summary__cfield on the Case.
Multi-Turn Lead Qualification
Use a stateful conversation to ask a prospect a series of questions over time, maintaining context across each step.
- Trigger: Lead is created.
- Action — Invoke Agent (Daemon): Stateful, no Conversation ID (starts a new conversation).
- Update Records: Store the returned Conversation ID on the Lead record.
- Later trigger: Lead stage is updated.
- Action — Invoke Agent (Daemon): Stateful, passing the stored Conversation ID. The agent continues the thread with full prior context.
Classify Incoming Emails
Trigger on new Email Message records. The agent classifies the intent and urgency, and the Flow routes accordingly.
- Trigger: Email Message is created.
- Action — Invoke Agent (Daemon): Send the email body as the message.
- Decision: Parse the agent's response (e.g. "urgent", "billing", "general").
- Branch: Route to the appropriate queue or create a high-priority Case.
Tips
Keep messages focused. The clearer and more specific your message input, the better the agent's response. If the task depends on record data, include the relevant fields in Host Context JSON rather than embedding them as raw text in the message.
Use stateful mode for multi-step tasks. If you need the agent to accumulate information across several steps in a process, a stateful conversation lets it build up context naturally rather than re-establishing it every time.
Store Conversation IDs on records. For long-running stateful workflows, persist the Conversation ID on a Salesforce field so it survives across separate Flow executions, batch jobs, or time-triggered automations.
Watch the timeout. Complex agent tasks — especially those involving multiple tool calls, large datasets, or code execution — can take significant time. If you're consistently hitting the 120-second limit, consider splitting the work across separate invocations or simplifying the agent's task scope.