Run a DocGen Package using Agentforce

You can now use Salesforce Agentforce to run a DocGen Package from a Salesforce record. This allows you to chat with an AI assistant (an Agentforce “Agent”) that helps you quickly generate a document and attach the document back to any Salesforce record. This uses the same DocGen Packages you have set up previously, that you can run from buttons using the DocGen lightning component.

In order to use this feature, additional set up is required by a Salesforce admin.

In this topic you will be guided on creating a new agent from within Salesforce and how to use that agent to run a DocGen Package directly from a Salesforce record.

Note: Currently the only delivery option available for use with Agentforce is the Attach delivery option.

Agentforce requirements for use with Nintex DocGen

In order to get started with using Agentforce you will need to have the following:

  • Agentforce set up and enabled for your Salesforce environment

  • Nintex DocGen for Salesforce installed

  • Nintex DocGen Agentforce extension

    • This is a free extension that can be downloaded directly from the Salesforce AppExchange

  • A DocGen Package already created for the record you are trying to run the package from (e.g. Opportunity)

  • Requires the use of Nintex DocGen's automation feature to be enabled. Check with your Account Manager to see if you are licensed to use automation.

Adding DocGen capabilities to your Agent

Once you have the above installed/ configured, you will need to add Nintex DocGen capabilities to an Agentforce Agent. Out-of-the-box Salesforce provides an Agent called “Agentforce”, and so typically you will link DocGen’s capabilities to this, but you can create your own Agent from scratch too. To find your existing Agent(s), you will need to go into Setup in your Salesforce Org, then Einstein->Einstein Generative Ai->Agent Studio->Agents or simply search for “Agents” in the Setup navigation search.

Once you’ve found the “Agentforce” Agent (or an Agent of your choice), you will need to configure the following items:

  • Create a series of DocGen specific Agent Actions

  • Create a new Agent Topic

  • Link the DocGen Actions into the Topic

Create DocGen specific agent actions

  1. In Salesforce Setup, use the Quick Find Quickfind boxaction or left-hand navigation menu to locate Agent Studio., or locate Agent Studio in the left-hand navigation menu.

  2. Expand Agent Studio and select Agent Actions.

  3. In Agent Actions, click New Agent Action. You will be creating three new agent actions:

    1. Find Document Package

    2. Find Delivery Option

    3. Run Document Package

  4. In Reference Action Type, select Apex.

    Note: If you are setting up Agentforce in a Salesforce developer environment you will need to select Invocable Methods in the Reference Action Category field.

  5. In Reference Action, search for and select Find Document Package.

    Note: In this example we will cover creating the Find Document Package option, however you will need to create two more agent actions from Find Delivery Option and Run Document Package using the same steps.

  6. Once the reference action is selected, the Agent Action Label and Agent Action API Name fields get auto-populated with default names. It is recommended to leave these fields as the default names.

  7. Click Next.

  8. On the next screen, locate the Ouput section and select the Show in Conversation option.

  9. Click Finish to create the new agent.

  10. Repeat the same steps for the Find Delivery Option, and Run Document Package actions.

  11. Once all three agents have been created they will now show up in the Actions list.

Build new Nintex DocGen topics for use with Agentforce

After the Nintex DocGen actions have been added, we can now go and add to the Agentforce Agent that your users will then be able to use from the Salesforce Agent chat interface to run a Document Package to generate documents.

  1. In Salesforce Setup, locate the Agent Studio option.

  2. Expand Agent Studio and select Agents.

  3. On the Agents screen, select the Agentforce agent.

  4. Once the agent details screen loads, click Open in Builder.

  5. In Topic Details, click New and then select the New Topic option from the drop-down menu.

  6. In the Topic Configuration section enter in the following information for each field:

    Important: For the following configurations and instructions, it is very important to copy the text below and paste the text into their appropriate fields exactly as is. Please do not make any changes or adjustments to the following options.

    1. Topic Label: Document Generation

    2. Classification Description:This topic is for all document generation and creation for any salesforce object. It can help the user generate documents for many use cases, including sending documents to customer partners or colleagues/co-worker. Users might ask to generate create, or send documents related to a record.

    3. Scope: Your job is to identify a document package the user wants to run, and then generate a document for the user for the reason they have stated, and either allow the user to download the generated document or have it sent or stored in a useful place.

  7. In Topic Configuration, under the Instructions section you will need to add the following instructions using the Add Instruction button:
    1. Instruction 1: Always start by finding the current record the user is looking at.
    2. Instruction 2: Always start by calling find best DDP action to find the best loop_ddp__c record for the document package user wants to use.
    3. Instruction 3: Always ask for confirmation before calling run document package. Confirmation must include name of the current record and document name.
    4. Instruction 4: Always find the name of the current record.
    5. Instruction 5: never display document package id
  8. Click Save.
  9. Select This Topic's Actions option.
  10. In This Topic's Actions, click New and then select Add from Asset Library from the drop-down menu.
  11. This displays a list of all available actions. Based on how many actions you have already created Agentforce or other integrations you may need to search for the agent actions you created specifically for Nintex DocGen. Locate the DocGen actions you created earlier and select each one.
    1. Find Document Package
    2. Find Delivery Option
    3. Run Document Package
  12. Once all three have been selected, click Finish.
  13. Click Activate to complete the build.

Note: You can use the Conversation Preview window to preview the chatbot and ensure that the AI assistant is working as intended.  However, note that in order forrom this preview to work you will need to have Salesforce records that already have existing Document Packages set up for use with that record. For example, if you wanted to test the chatbot to run a Document Package for a Salesforce Opportunity, you will need to have already created a Document Package related to the Opportunity in Salesforce.

What can users ask the Agent to do?

After setting up the DocGen actions and creating the topics, it is oissand actions you’ve configured from within the Agent Builder. If you choose to do this, use the types of questions/ requests covered in the “Run a Document Package from a Salesforce record using Agentforce” below to test.

A couple of tips:

  • Use the Eye icon at the top of the Conversation preview pane, to target the conversation as if it has been started from a record page; you can choose a specific Salesforce record for it to use.

  • When repeatedly testing the same request, in many circumstances you can just type “again” into the conversation for it to repeat the previous operation.

Run a Document Package from a Salesforce record using Agentforce

Now that a new actions have been added, and new topics have been created from the Einstein Copilot, you can use the Agentforce AI assistant to run a Document Package directly from a Salesforce record. In this section we will go over an example of how to use Agentforce to run a Document Package.

  1. In Salesforce, open a record that has a Document Package created that is using the Attach delivery option. In this example, we are going to use an Opportunity.

  2. From the record, click the Agentforce icon to display the Agentforce agent.

  3. Begin chatting with the chatbot.

    Trying typing "Generate me a document for this opportunity".

  4. The agent will then attempt to locate a Document Package related to the current Opportunity you have opened. If it succeeds it will ask for confirmation to proceed with the document generation. If you have more than one type of document that can be generated from the record you have opened it may ask which with document you want to use.

    Note: It will only find Document Packages with the "Attach" delivery option configured on them.

  5. Once you confirm, the document generation process will continue and the document will be attached to the record. Refresh the "notes and attachments" on the Opportunity until you see the generated document.

Try out different prompts!

Remember that the Nintex DocGen capabilities we’ve added to the Agentforce agent can be used in conjunction with the other capabilities the agent has out of the box, like finding records and updating records.

For example, lets say you were looking to generate a document for an opportunity in Salesforce, but before generating the document you wanted to make a quick change to the Opportunity record first. By using Agentforce, you can combine both requests at the same time.

Example prompts:

Example 1: “Create a proposal for this” – from an opportunity record page, you could ask the Agent this, and it will know what you mean by “this”, and will find any DocGen Packages targeting the Opportunity object, with “Proposal” in the name of the package.

Example 2: “What are my top opportunities right now?” – from the home tab of Salesforce (i.e. not a record page), then once it replies with a short list you could say “I’d like to create a proposal for the second one”, at which point the Agent will route the request for Nintex DocGento generate a document for that record.