⚡ Daemon
📖 How to invoke an agent synchronously from Salesforce Flows and automated processes.
Overview
The Daemon is an invocable Apex action that lets you call a Flourish agent directly from a Salesforce Flow, Process Builder, or any other Apex context — without a user or a 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 its text response synchronously. The caller waits for the result.
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.
⏱️ The Daemon has a 120-second timeout. For tasks that may take longer, consider breaking the work into smaller steps or using an asynchronous pattern.
Finding It in Flow Builder
In Flow Builder, add an Action element and search for:
Invoke Agent (Daemon)
It appears under the Flourish Agent Platform category.
Input Variables
| Variable | Required | Description |
|---|---|---|
| Agent External Id | ✅ | The Flourish Agent Platform UUID 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. This is the equivalent of a user's chat message. |
| Stateful | — | Set to true to start or resume 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. |
Output Variables
| Variable | Description |
|---|---|
| Response | The agent's text response. |
| Conversation Id | The conversation UUID. Only populated for stateful calls — store this in a Flow variable to pass back on the next turn. |
Stateless vs Stateful
Stateless (default)
Each invocation is completely independent. The agent has no memory of previous calls. Use this for one-shot tasks: summarizing a record, classifying a piece of text, generating a draft email.
Stateful: false (or leave blank)
Conversation Id: (leave blank)
Stateful
The agent maintains conversation history across calls. The first call starts a new conversation and returns a Conversation Id. Subsequent calls pass that ID back to resume the thread — the agent will remember everything said so far.
First call:
Stateful: true
Conversation Id: (leave blank)
→ Returns Conversation Id: "conv-abc-123"
Second call:
Stateful: true
Conversation Id: "conv-abc-123"
→ Agent continues from where it left off
Store the Conversation Id output in a Flow variable (or on a Salesforce record) if you need to resume the conversation later — even across separate Flow executions.
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 object is accepted. For example, passing 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.
Multi-Turn Qualification Flow
Use a stateful conversation to ask a prospect a series of questions over time (e.g. triggered by different record updates), maintaining context across each step.
Classify Incoming Emails
Trigger on new Email Message records. The agent classifies the intent and urgency, and the Flow routes accordingly.
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.
For multi-step tasks, use stateful mode. 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 on every call.
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 timeouts, consider splitting the work across separate invocations or simplifying the agent's task scope.