---
title: "Build complex automation with Apex Actions"
url: "https://docs.signnow.com/docs/salesforce-automation-apex-actions"
type: "page"
section: "Integrations"
slug: "salesforce-automation-apex-actions"
---

# Build complex automation with Apex Actions

# Automate language-specific welcome packets with Salesforce Flow and SignNow Apex actions

This guide demonstrates how to automate language-specific onboarding packets in Salesforce using Salesforce Flow and SignNow Apex actions. With this setup, your team can deliver a seamless, personalized onboarding experience for every new client—instantly and without manual intervention.

## Use case overview

When a new client is acquired, AcmeCompany wants to immediately send a personalized welcome email with a link to the onboarding packet. The company serves both English and French-speaking clients and wants the experience to be native to the user's language.

**How it works:**

- The rep updates the Contact's `Lead Source` to `Web`.
- A Salesforce Flow runs in the background. It first uses standard logic to detect the client's language and assign the correct onboarding template ID. Then, it triggers SignNow Apex actions to generate the embedded signing link, finally saving that link back to the Contact's record.
- The moment that link is saved, a second Salesforce Flow fires to trigger the correct pre-configured email alert (English or French), ensuring the client receives the right message with the right link.

---

## Prerequisites

Before building the flows, ensure the following are ready in your Salesforce Organization:

- The SignNow package must be installed.
- Create a custom field: Create a URL or Text field on the Contact object to store the generated signing link. For example, `SignNow embedded signing URL`.

The custom field must be API-accessible and included in the page layout for visibility.

**Note**: You can use any Salesforce object and custom field.

- Create SignNow templates in English and French, and configure them to pre-fill with Salesforce data.

---

### How to create a SignNow template

- Go to **SignNow Admin Tools** > **Templates**.
- Click **Create New Template**.
- Upload onboarding documents. The documents will appear in the list of templates.
- Click **Add Fillable Fields** to add a text, date, and signature field to your template.

![template_add_fields_new.png](/reference-assets/images/SignNow_Salesforce/use_case_apex/template_add_fields_new.png)

- Click **Done** to save the changes.

> Learn more about [adding fillable fields](/docs/templates#add-fillable-fields).

- Click **Pre-fill Fillable Fields** to map fillable fields in the template with Contact record data.
- Select fillable fields in the template and connect them to Contact fields. For example, pre-fill the text field with `Full Name`, and the date field with `Last Modified Date`.
    
![template_prefill.png](/reference-assets/images/SignNow_Salesforce/use_case_apex/template_prefill.png)

> Learn more about [pre-filling fillable fields](/docs/templates#pre-fill-fillable-fields).
- Click **Save** to save the changes.

---

- (Optional) Create SignNow document flow for each template. Use a document flow if you want to apply specific flow settings like redirect URLs or additional pre-fill logic.

---

### How to create a SignNow document flow

- Go to **SignNow Admin Tools** > **Document Flows**.
- Click **Create Document Flow**.
- [Customize your Document Flow](/docs/document-flows) as your automation needs. For example, pre-fill the client email using the `Contact.Email` field.
    
![template_doc_flow.png](/reference-assets/images/SignNow_Salesforce/use_case_apex/template_doc_flow.png)

- Click **Save** to save the Document Flow.

---

- Create Salesforce email templates in English and French.
  - Add a merge field to each email template that will be pre-filled with the generated SignNow signing link.

![email_template_merge_field.png](/reference-assets/images/SignNow_Salesforce/use_case_apex/email_template_merge_field.png)

Use the email templates to send email alerts in the Flow configuration.

---

## Configuration guide

## Flow 1 (asynchronous)

**Overview**: This Salesforce Flow checks the preferred client language, assigns the SignNow template based on the language, generates the signing link for the template, and stores the link to the custom field.

## Step 1. Create the flow

- Go to **Flow Builder**.
- Select the **Record-Triggered Flow** type.
- Set up the triggering conditions (e.g., Object: `Contact`, Trigger: `A record is updated`).
- Define the entry criteria (e.g., when the `Lead Source` equals `Web`).
- Configure the path to **Run Asynchronously**.
    - **Note**: We must use the asynchronous path because the SignNow Apex actions perform external web callouts.

![flow1_trigger.png](/reference-assets/images/SignNow_Salesforce/use_case_apex/flow1_trigger.png)

## Step 2. Add check language decision

- Click the **(+)** icon under the start trigger to add a **Decision** element.
- Add a label.
- Create outcomes to check if the client's preferred language is **French** or **English**.
- **Outcome 1 (French):** `Triggering Contact` > `Preferred language` Equals `French`.
- **Outcome 2 (English):** Default outcome.

![flow1_decision.png](/reference-assets/images/SignNow_Salesforce/use_case_apex/flow1_decision.png)

## Step 3: Add SignNow template and document flow assignments

Assign SignNow template and document flow IDs.

> If you are not using document flows, you can omit the `FlowID` variable and related assignments. 

- In the toolbox (Manager tab), create two new **Variable** resources:
    - `TemplateID` (Data Type: **Text**): Used to assign the SignNow template.
    - `FlowID` (Data Type: **Number**): Used to assign the SignNow document flow.
- Click the **(+)** icon on the **French path** to add an **Assignment** element.
    - Add a label.
    - Set variable values:
        - `TemplateID` **Equals** [Your French SignNow template ID].
        - (Optional)`FlowID` **Equals** [Your French document flow ID].

**Note**: To copy the template or document flow ID, go to **SignNow Admin Tools** > **Templates** or **> Document Flows.**

- Click the **(+)** icon on the **English path** to add an **Assignment** element.
    - Add a label.
    - Set variable values:
        - `TemplateID` **Equals** [Your English SignNow template ID].
        - `FlowID` **Equals** [Your English document flow ID].

![flow1_assignment.png](/reference-assets/images/SignNow_Salesforce/use_case_apex/flow1_assignment.png)

## Step 4. Add SignNow Apex actions

> Before using SignNow Apex Actions, complete [these prerequisites](/docs/salesforce-apex-actions#prerequisites).

Click the **(+)** icon on the path to add **Action** elements sequentially. 

### **Action: Create SignNow Document Group from SignNow Template**

This action creates a document group from the English or French SignNow template.

- Click **(+)** and add **Create SignNow Document Group from SignNow Template action.**
- Add a label.
- Set input values:
    - `SignNow Document Group Template ID`: select the `TemplateID` variable.
    - (Optional) `Record ID`: `Triggering Contact > Contact ID`
    - (Optional) `SignNow Document Flow ID`: Select the `FlowID` variable.
    - (Optional) `SignNow Document Group Name`: `Welcome Package` (or your preferred name).

![flow1_create_dg_action.png](/reference-assets/images/SignNow_Salesforce/use_case_apex/flow1_create_dg_action.png)


### **Action: Get SignNow Document Group Recipients**

This action retrieves the information about the created document group recipients, including email addresses.

- Click **(+)** and add **Get SignNow Document Group Recipients** action.
- Add a label.
- **Set input values:**
    - `SignNow Document Group ID`: Select `Outputs from Create SignNow Document Group from SignNow Template` > `SignNow Document Group ID`.

![flow1_get_dg_recipients_action.png](/reference-assets/images/SignNow_Salesforce/use_case_apex/flow1_get_dg_recipients_action.png)

### **Action: Create SignNow Embedded Invite**

This action creates an embedded invite for the new document group.

- Click **(+)** and add **Create SignNow Embedded Invite** action.
- Add a label.
- **Set input values:**
    - `SignNow Document Group ID`: Select `Outputs from Create SignNow Document Group from SignNow Template` > `SignNow Document Group ID`.
    - `SignNow Embedded Invites`: Select `Outputs from Get SignNow Document Group Recipients` > `SignNowEmbedded Invites`.

![flow1_create_embedded_invite_action.png](/reference-assets/images/SignNow_Salesforce/use_case_apex/flow1_create_embedded_invite_action.png)

### **Action: Get SignNow Embedded Signing Session URL**

This action creates an embedded signing link for the document group.

- Click **(+)** and add **Get SignNow Embedded Signing Session URL** action.
- Add a label.
- **Set input values:**
    - `Email`: `Triggering Contact` > `Email`.
    - `SignNow Document Group ID`: Select `Outputs from Create SignNow Document Group from SignNow Template` > `SignNow Document Group ID`.
    - `SignNow Embedded Invite ID`: Select `Outputs from Create SignNow Embedded Invite` > `SignNowEmbedded Invite ID`
    - (Optional) `Link Expiration`: Set to **45** minutes or less.

![flow1_embedded_url_action.png](/reference-assets/images/SignNow_Salesforce/use_case_apex/flow1_embedded_url_action.png)

## **Step 5: Update contact record**

- Click the **(+)** icon to add an **Update Records** element.
- Add a label.
- **How to Find Records to Update:** Select **Use the contact record that triggered the flow**.
- **Set Filter Conditions:** Leave as **None—Always Update Record**.
- **Set Field Values for the Contact Record:**
    - **Field:** Search for and select `SignNow embedded signing URL`.
    - **Value:** Select `Outputs from Get SignNow Embedded Signing Session URL` > `SignNow Embedded Signing Session URL`.


![flow1_update_record.png](/reference-assets/images/SignNow_Salesforce/use_case_apex/flow1_update_record.png)


## **Step 6. Finalize the flow**

- Click **Save**.
- **Activate** the flow.

---

## Flow 2: The "messenger" (real-time)

This Salesforce Flow waits for the signing link to appear and triggers the email alert.

## **Step 1: Create the flow**

- Go to **Flow Builder**.
- Select the **Record-Triggered Flow** type.
- Set up the triggering conditions:
    - **Object:** Select **Contact**.
    - **Trigger:** Select **A record is updated**.
- Define the entry conditions to ensure the flow only runs when the signing link is generated:
    - **Field:** `SignNow embedded signing URL`
    - **Operator:** **Is Changed**
    - **Value:** `True`
- **When to Run the Flow for Updated Records:** Select **Every time a record is updated and meets the condition requirements**.
- Choose to optimize the flow for **Actions and Related Records**.

![flow2_trigger.png](/reference-assets/images/SignNow_Salesforce/use_case_apex/flow2_trigger.png)

## **Step 2: Add check language decision**

- Click the **(+)** icon under the start trigger to add a **Decision** element.
- Add a label.
- **Outcome 1 (French):** Set the condition where `Triggering Contact` > `Preferred language` **Equals** `French`.
- **Outcome 2 (English):** Default outcome.
- **When to Execute Outcome:** If the condition requirements are met.

![flow2_decision.png](/reference-assets/images/SignNow_Salesforce/use_case_apex/flow2_decision.png)

## **Step 3: Add email alert actions**

- **French path:**
    - Click the **(+)** icon to add **Send** **Email Alert** element.
    - Search for and select your **French Email Alert**.
    - Add a label.
    - **Set Input Values:**
        - **Record ID:** `Triggering Contact` > `Contact ID`.
- **Default outcome (English path):**
    - Click the **(+)** icon to add **Send** **Email Alert** .
    - Search for and select your **English Email Alert**.
    - Add a label.
    - **Set Input Values:**
        - **Record ID:** `Triggering Contact` > `Contact ID`
    
![flow2_email_alert.png](/reference-assets/images/SignNow_Salesforce/use_case_apex/flow2_email_alert.png)  

## **Step 4. Finalize the flow**

- Click **Save**.
- **Activate** the flow.

---

## Result

Once activated, this automation delivers a seamless onboarding experience. As soon as a Contact's **Lead Source** is updated to **Web**, the system instantly generates a personalized SignNow signing link to the onboarding packet and triggers a branded email in the client's preferred language (English or French). This eliminates manual data entry and ensures every new client receives their documents immediately.

---

Learn more about [SignNow Apex Actions](/docs/salesforce-apex-actions).


---
*Full page: https://docs.signnow.com/docs/salesforce-automation-apex-actions*
