Documill Dynamo

Setting up Agentforce with Documill

Prerequisites

  1. Install the Documill document generation package from AppExchange.
    https://appexchange.salesforce.com/appxListingDetail?listingId=a0N30000009whyxEAA
    Detailed instructions can be found here.

  2. Install the Agentforce connector package from AppExchange.
    https://appexchange.salesforce.com/appxListingDetail?listingId=efb6d55a-fe5b-48cf-b256-e168d8300b58

  3. Set-up your Salesforce OAuth 2.0 client credentials flow.
    No-code API setup for Salesforce Flows

    This step is required to properly communicate with external apps based on Salesforces' security requirements.


Permissions

To generate documents with Documill, you will need to assign the appropriate Documill permission set to the user who has been declared in step 3 of the pre-requisites.
https://support.documill.com/dynamo/user-permission-sets

Documill uses Salesforce to handle all permissions. Any user generating the document, will need to have at least read permissions on the template file and any objects and records used within the document.


Setting up the Agent

If you do not yet have an Agent, now is the time to create one. From the Salesforce setup, open Agentforce Agents.

{B1930111-F19F-4FE6-94AF-8022A38B6E5D}-20260508-114057.png

From here, you can either modify an existing agent, or create a brand new one using the “+New Agent” button on the top right.


If creating a new Agent, we suggest using the “Agentforce Employee Agent” as the starting point.

{DFAB930F-E1D7-44BB-9F36-585FC06DCEB8}-20260508-114148.png



From within the Agentforce Builder, create a new Subagent. Subagents will be able to trigger Documill later on.

{FCB41BA2-4E5D-4670-9805-215AD6C92DCD}-20260508-114310.png


Next, configure your Agent’s instructions based on your needs.

Example Subagent

Description: Summarizes an Opportunity and runs Documill flow

Scope: Only handle Opportunity summarization and flow triggering

Example input:

“Create Quote for this opportunity 006XXXXXXXX”

“Create a proposal for [name of the opportunity] opportunity”

Instructions to include: 

  1. Retrieve record ID from the current opportunity tab 

  2. Alert user if products or contacts are missing 

  3. Use any 18-digit ID starting with 006 as an Opportunity ID 

  4. Inform if Opportunity Products or Contact Roles are empty 

  5. Extract record ID from URLs or opportunity names if no ID is given 

  6. Validate input before executing flows 

  7. Set OppID = recordId 


After the Subagent has been given proper instructions, include the relevant Actions. The package comes with 2 pre-defined actions, one for generating single Quotes from Opportunity records, and the second for mass document generation. The Query Records action is also needed.

{E82A8B71-9171-4C69-87B8-56D6C72011B0}-20260508-114844.png


Click “Finish” and now your new Subagent will appear on the list.

{7FB90C14-028C-4E19-951F-15EB9677306D}-20260508-115011.png


At this stage, its advised to test the agent and see if the correct Subagent is triggered.

{F4EF4B53-A1E7-4C88-8DFB-13AACBCD51D8}-20260508-115305.png

In this case, the Documill subagent we just created triggered as expected.


Configure the Flow

The two actions included in the Agentforce connector package are designed to trigger a Salesforce flow which in turn will communicate with Documill via API to generate the desired document. As this flows require customer specific information, they need some additional configuration before use.

From the Salesforce Setup, navigate to “Flows”

{9CF545D2-3631-4EFA-BED9-04ABC7039BE2}-20260508-115554.png


Here, you will find 3 flows which were included in the Agentforce connector package.

{DB399746-DCE1-43AE-9EAA-F75928011137}-20260508-115645.png


The exact structure of the Flow will depend on your needs. Bellow you can find two simple examples:

Task API Use Case

Using flow (Task API)

Setup -> Process Automation -> Flows

  1. Create new Flow (like Screen Flow)

  2. Add new External Services Action element. This element should be the External Service operation ‘Post Task’ that was created previously. Now ‘Body’ should be listed in action’s Input Values. Give it value:

a.       New Resource -> Variable

b.       API Name -> “PostTaskBody” (could be anything)

c.       Data Type -> Apex-Defined

d.       Apex Class -> Select Dynamic Apex class that is created by External Services. Usually it is named like this:
ExternalService__<External Service name>PostTaskRequest
or similar.

Screenshot 2025-10-24 100856-20251024-070856.png
  1. Assign request body by creating ‘Assignment’ element before the action element. Give it a Label and Name. Each of the body property is set separately. Flow Builder should suggest the previously constructed Apex-Defined variable when searching for variables.

Screenshot 2025-10-24 111302-20251024-081302.png


To retrieve the record, create a new variable as so:

image-20260508-141814.png

The API Name OppID was defined in the Agent instructions above.

Once this variable is created, set it as the <recordID> in the assignmnet action.

When implementing for Experience Cloud, the serverURL above needs to be set as the Lightning url in this format:MyDomainName.my.salesforce.com

Screenshot 2025-10-24 111332-20251024-081332.png

Flow should be now set and ready for testing.


Batch API Use Case

Using flow (Batch API)

Setup -> Process Automation -> Flows

  1. Create new Flow (like Screen Flow)

  2. Add new External Services Action element. This element should be the External Service operation ‘Post Batch’ that was created previously. Now ‘Body’ should be listed in action’s Input Values. Give it value:

    1. New Resource -> Variable

    2. API Name -> “body” (could be anything)

    3. Data Type -> Apex-Defined

    4. Apex Class -> Select Dynamic Apex class that is created by External Services. Usually it is named like this:
      ExternalService__<External Service name>PostBatchRequest
      or similar.

  3. Assign request body by creating ‘Assignment’ element before the action element. Give it a Label and Name. Each of the body property is set separately. Flow Builder should suggest the previously constructed Apex-Defined variable when searching for variables, similar to creation of Flow for Task API. Only exception is made when defining task array objects; each of the task objects must be constructed separately in Flow. To do that:

    1. Select Variable as body > tasks

    2. Operator as Add

    3. Value as New Resource -> Variable -> Give it a name (i.e. taskVar) -> Data Type as Apex-Defined -> Select Apex Class, that is named similar to this
      ExternalService__<External Service name>_PostBatchRequest_tasks

      Add these task objects as many as needed.

Screenshot 2025-11-13 150050-20251113-130051.png

When implementing for Experience Cloud, the serverURL above needs to be set as the Lightning url in this format:MyDomainName.my.salesforce.com

  1. Before Flow is ready, previously created task objects needs “params” and “id” properties as stated in Post Batch documentation. New Assignment element is needed and placed before the body assignment element. Simply just give field values to task objects (taskVar > params > id) and Flow should be now ready for testing.

Screenshot 2025-11-13 151833-20251113-131833.png
Screenshot 2025-11-13 152753-20251113-132753.png

Note:
If the batch body content size grows substantially large and complex, consider implementing the integration using an HTTP callout instead of External Services. HTTP callouts provide easier control over request construction, allowing greater flexibility for modifying and managing the request body content.


All Flows will require a Documill template to run. Please reffer to the following article and learn how to create an API template Create or change an API template or use this sample Opportunity Quote template: Quote Sample.dap


Testing the Agent

Now that all the components have been created, it is time to test the agent. Ensure that both the Agent and Flows are activated.


From the desired record, open the agent and give them a meaningful prompt that your users may use.

{0FEC36D4-68C2-486C-B517-83F9FC5D658B}-20260508-121401.png


The Agent will then confirm that the process has been completed.

{0A73F307-4866-4BFF-BBC3-849C3A113BBB}-20260508-121514.png


From here, the Agent can be further customized or tuned based on your own needs and prefferences. As this integration is quite modular, the possible application are endless. Try adding prompt templates to the flow for enhanced content creation!