Knowledge Base - Smart Flows

Generating Documents with Smart Flows in Salesforce

Overview

Once your Experlogix Smart Flows connector is configured with the Second-Generation Salesforce App, there are three ways to initiate document generation within Salesforce: manually via a button on a record, automatically through Salesforce Flow Builder, or agentically through an Agentforce AI agent.

This article provides a comprehensive guide on how to provide user access, configure manual buttons, set up automated document generation triggers, and connect an AI agent.

Scenario

Business Context:

You want to empower your sales team to manually generate quote documents directly from an Opportunity record when they are ready. Simultaneously, you want the system to automatically generate a Welcome Letter in the background as soon as an Account's status changes to "Active." You need to understand how to configure access and triggers for both manual and automated scenarios.

Granting User Access

Before your Salesforce users can see the Experlogix Documents button or successfully trigger an automated flow under their context, they must have the correct permissions assigned in Salesforce.

A Salesforce System Administrator must assign at least the Experlogix Documents User permission set to any user who needs to generate documents.

How permissions affect the process:

  • If a user does not have the Experlogix Documents User permission set, they will not see the Experlogix Documents button on their page layouts, even if the administrator has added it.

  • If an automated flow runs under the context of a user without this permission set, the document generation request will fail with an access denied error.

  • An AI agent does not run under the context of a Salesforce user. It authenticates against the Smart Flows MCP server with the API key of a Smart Flows user, and it can only discover and execute the flows that this Smart Flows user is allowed to run. Salesforce permission sets therefore do not apply to it.

(For detailed information on configuring Smart Flows roles, refer to our main User Management Guide.)

Starting a Smart Flow Manually (Experlogix Documents Button)

The most common way end-users interact with Smart Flows is by selecting a dedicated button on a Salesforce record.

Visibility Requirements

For an end-user to successfully see the button and open the execution panel:

  • The user must be assigned the Experlogix Documents User permission set.

  • The Salesforce Administrator must have added the button to the object's Page Layout.

  • There must be at least one active Smart Flow deployed and configured to run for that specific Salesforce object.

Button Configuration (Administrators)

To make the button available:

  1. Enable the Object: In the Smart Flows Project Console, navigate to your Salesforce connector configuration. At the Select Salesforce objects stage, select the objects (e.g., Opportunity, Account) that should receive a button. At the preceding Install Smart Flows buttons stage, you choose whether this is done automatically by the connector setup or manually.

  2. Add to Page Layout: In Salesforce, go to Setup > Object Manager > select the object > Page Layouts. Drag the Experlogix Documents action from the "Mobile & Lightning Actions" palette onto your layout and save.

Executing a Flow (End-Users)

  1. Navigate to a Salesforce record (e.g., an Opportunity).

  2. Select the Experlogix Documents button on the record's action menu.

  3. The Smart Flows Execution Panel opens securely over your Salesforce record.

  4. Select a flow, and select Run.

Starting a Smart Flow Automatically (Salesforce Flow)

You can fully automate document generation using Salesforce Flow Builder. The AgentExchange package includes actions specifically designed for Experlogix Document Automation that you can add to your Salesforce flows.

Experlogix Actions

In Flow Builder, these actions are grouped under the Experlogix Document Automation Actions category. Two actions are available:

Action

API name

Description

Start an ExperlogixDocuments Flow Execution

apex-Xplx__ExperlogixDAStartFlowExecution

Initiates a specific Smart Flow in the background by passing the ID of the current Salesforce record to the Smart Flows engine.

Get an ExperlogixDocuments Flow Execution Status

apex-Xplx__ExperlogixDAGetExecutionStatus

Checks the current execution status of a flow previously initiated by the start action (useful when waiting for large documents to finish generating).

Note: If these actions do not appear in the Action element search, the Experlogix Document Automation package is either not installed in your organization or the running user does not have the required permission set.

Using Experlogix Actions in Flow Builder

To set up an automated trigger:

  1. In Salesforce, navigate to Setup > Process Automation > Flows and create a new flow (for example, a Record-Triggered Flow).

  2. Define your trigger criteria (e.g., Account Status equals "Active").

  3. In the Toolbox, select New Resource and create a Variable named recordid of type Text. This variable holds the ID of the record that Smart Flows uses as the triggering record for the execution.

  4. Add an Assignment element that sets recordid to {!$Record.Id}.

  5. Add a new Action element to the canvas.

  6. Search for and select Start an ExperlogixDocuments Flow Execution.

  7. Set the input values for the action (see the table below). At minimum, provide the flow to run and pass {!recordid} as the record ID.

  8. Connect, Save, and Activate your Salesforce flow.

Whenever the criteria are met, Salesforce autonomously starts the Smart Flow without any manual user action.

Action Parameters

Start an Experlogix Documents Flow Execution

Parameter

Required

Description

Flow

Yes

The ID or the name of the Smart Flow to run. You can find both in the Smart Flows Project Console on the flow's detail page. Using the ID is more reliable, because renaming a flow does not break the automation.

Record ID

Yes

The ID of the Salesforce record that serves as the triggering record. Pass the recordid variable you declared, or {!$Record.Id} directly. Smart Flows uses this ID to retrieve the record data defined in the flow's data set.

Display name

No

A readable name for this execution. It appears in the execution history in the Project Console, which makes troubleshooting a specific run much easier. If you leave it empty, Smart Flows generates a default name.

User ID

No

Runs the execution on behalf of a specific Smart Flows user instead of the connector's integration user. Use this when the generated document or its audit trail must be attributed to the user who triggered the Salesforce automation.

Priority

No

Controls the position of this execution in the Smart Flows processing queue relative to other executions. Use a higher priority for time-critical documents, such as those generated while a customer is waiting.

Note: The action returns an execution ID. Store it in a variable if you plan to check the status later in the same Salesforce flow.

Get an Experlogix Documents Flow Execution Status

Parameter

Required

Description

Execution ID

Yes

The execution ID returned by the Start an Experlogix Documents Flow Execution action.

Output

No

The ID or name of a specific flow output to return, such as the generated document or a link to it. If you leave it empty, the action returns all outputs of the flow.

The action returns the current status of the execution, so your Salesforce flow can branch on whether the document generation succeeded, is still running, or failed.

Starting a Smart Flow from Agentforce AI

Experlogix Smart Flows includes a Model Context Protocol (MCP) server. The Model Context Protocol is an open standard that describes how AI agents discover and call external tools. Agentforce AI agents use this MCP server to start Smart Flows from within Salesforce.

Where the button is a manual, user-driven action and Salesforce Flow is a deterministic, rule-driven automation, an AI agent decides for itself when a document process is needed and which flow to run. The user has a conversation with the agent in Salesforce, and the agent calls the MCP server directly to discover, start, and follow up on the flow.

Registering the Smart Flows MCP Server

Register the Smart Flows MCP server as a connection in your Salesforce organization. Use the following values:

Field

Value

MCP Server Name

A name of your choice, for example ExperlogixDocuments.

Server URL

<https://mcp.smartflows.experlogix.com/runtime/webhooks/mcp>

Authentication Method

OAuth 2.0

Header name

X-API-Key

Header value

UserAPIKey;DAProjectURL

The header value is a single string that combines the API key of a Smart Flows user and the URL of the Smart Flows project, separated by a semicolon (;).

To generate the API key:

  1. Log in to the Smart Flows Project Console.

  2. Go to Security > Users.

  3. Select the dedicated integration user account.

  4. Generate a new API Key under the security settings of the user.

  5. Copy the API key and combine it with your project URL using the semicolon delimiter.

Note: Treat this API key as a highly sensitive password. If the key is ever compromised, you can revoke and regenerate it from the Smart Flows Project Console.

Tools Available to the Agent

The MCP server exposes the following tools:

Tool

Description

get_flows

Gets the list of flows that are available to execute. This is typically the first tool the agent calls, to discover which flows can be executed.

get_flow_schema

Gets the JSON schema for a specific flow. The agent always calls this tool before it executes a flow, to understand what data the flow expects.

execute_flow

Executes a specific flow.

get_execution_status

Gets the current status of a flow execution. The agent uses this to check whether an execution has completed, is still running, or has failed.

get_documents

Gets the list of documents generated by a completed flow execution. The agent calls this after an execution completes successfully.

download_document

Downloads the content of a specific document generated by a flow execution. The agent calls get_documents first, to obtain the document reference.

Typical Sequence

  1. get_flows - the agent discovers the flows that it is allowed to run.

  2. get_flow_schema - the agent inspects the input that the selected flow requires, and collects the missing information from the user if needed.

  3. execute_flow - the agent starts the flow.

  4. get_execution_status - the agent polls until the execution completes.

  5. get_documents - the agent retrieves the list of generated documents.

  6. download_document - the agent retrieves the document content and presents it to the user.

Security and Governance

Every execution that is started through the MCP server runs within the existing Smart Flows security, permission, and auditing framework. An AI agent is subject to exactly the same rules as any other execution channel, so administrators keep controlled access to the automation logic and retain full visibility into execution status, results, and generated artifacts.

Because the agent authenticates as a Smart Flows user, it can only discover and execute the flows that this user is allowed to run.