> ## Documentation Index
> Fetch the complete documentation index at: https://help.treble.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Launch conversations from a Flow

> How to install the Treble package in Salesforce to trigger a WhatsApp conversation from an automation flow.

<Note>
  The package is evolving, and its installation link changes with each new version. If something doesn't match what you see on screen, confirm with your Customer Success Manager that you're using the current version.
</Note>

So far, conversations are triggered from Treble. With this package you can do it the other way around: **a Salesforce automation flow triggers a Treble WhatsApp conversation**.

It's useful for cases like: when a lead changes to a certain status, automatically sending them a WhatsApp template; or when a request is created, starting the follow-up conversation without anyone having to do anything.

<div class="hr" />

## Before you start

| You need | Where to get it |
| - | - |
| A Salesforce administrator user | Your Salesforce team |
| The package installation link | It's further below, in step 1 |
| Your Treble API key | In the Treble platform: **Settings → Developers → API KEY** |

<Warning>
  The API key is a credential with access to your Treble account. Don't share it through open channels, don't paste it into shared documents, and if you think it was exposed, ask for it to be regenerated.
</Warning>

<div class="hr" />

## 1. Install the package

With your Salesforce session open, go to this link:

```
https://login.salesforce.com/packaging/installPackage.apexp?p0=04taj000000A3B7AAK
```

<Info>
  **About the link identifier.** The final part (`04taj000000A3B7AAK`) is the package version Id. When a new version is published, that Id changes.

  If the link doesn't open, asks you for an installation password, or installs something that doesn't match what you see here, you're probably using an old link: ask your Customer Success Manager for the current one.
</Info>

<Warning>
  If your org is a **sandbox**, replace `login.salesforce.com` with `test.salesforce.com` in the link.
</Warning>

You'll see the installation screen for the **DeployTrebleConversation** package.

<img src="https://mintcdn.com/trebleai/n_48dzI5l_tB6XfZ/images/salesforce-flow-package-1.png?fit=max&auto=format&n=n_48dzI5l_tB6XfZ&q=85&s=707e69ebb721781592a855e728f54b97" alt="Installation screen for the DeployTrebleConversation package" className="mx-auto" width="1052" height="578" data-path="images/salesforce-flow-package-1.png" />

Choose who can use it:

| Option | When to use it |
| - | - |
| **Install for Admins Only** | Recommended to start. Only administrators can use it while they test it |
| **Install for All Users** | When it's already validated and several teams are going to use it |
| **Install for Specific Profiles** | When you want to limit it to certain profiles |

Click **Install** and wait for Salesforce to confirm the installation.

<div class="hr" />

## 2. Configure the credential

The package installs an **external credential** and a **named credential**, which are what allow Salesforce to call the Treble API.

<img src="https://mintcdn.com/trebleai/n_48dzI5l_tB6XfZ/images/salesforce-flow-package-2.png?fit=max&auto=format&n=n_48dzI5l_tB6XfZ&q=85&s=e975c1aacb76561f172db7ecb2557631" alt="Treble external credential detail" className="mx-auto" width="1651" height="776" data-path="images/salesforce-flow-package-2.png" />

<Steps>
  <Step title="Open Setup → Named Credentials">
    You'll see the external credential `treble_api_external_credential` and, related to it, the named credential `treble_api`.
  </Step>

  <Step title="Confirm the URL (usually you don't need to touch it)">
    The package already comes with the credential pointing to `https://main.treble.ai`. You don't have to configure it: just verify that it's set that way.
  </Step>

  <Step title="Add the authorization header">
    In the external credential, in the **Custom Headers** section, click **New** and create:

    | Field | Value |
    | - | - |
    | **Name** | `Authorization` |
    | **Value** | Your Treble API key |
    | **Sequence Number** | `1` |

    Save.
  </Step>
</Steps>

<div class="hr" />

## 3. Give users permissions

Salesforce doesn't allow using an external credential without an explicit permission. The package comes with a ready-made permission set.

<Steps>
  <Step title="Open Setup → Permission Sets">
    Look for the `treble_api_permission` permission set.

    <img src="https://mintcdn.com/trebleai/n_48dzI5l_tB6XfZ/images/salesforce-flow-package-3.png?fit=max&auto=format&n=n_48dzI5l_tB6XfZ&q=85&s=bcf6ffcac3840375cabebb77d2fee7a6" alt="The treble_api_permission permission set" className="mx-auto" width="1654" height="366" data-path="images/salesforce-flow-package-3.png" />
  </Step>

  <Step title="Confirm access to the credential">
    Inside the set, go to **External Credential Principal Access** and verify that the Treble principal is there.

    <img src="https://mintcdn.com/trebleai/n_48dzI5l_tB6XfZ/images/salesforce-flow-package-4.png?fit=max&auto=format&n=n_48dzI5l_tB6XfZ&q=85&s=26505e27c94ebf52dee74c6e8ba7da02" alt="External Credential Principal Access section" className="mx-auto" width="1633" height="738" data-path="images/salesforce-flow-package-4.png" />
  </Step>

  <Step title="Assign the set to users">
    Click **Manage Assignments → Add Assignments** and select the users who are going to run the flows.

    <img src="https://mintcdn.com/trebleai/n_48dzI5l_tB6XfZ/images/salesforce-flow-package-5.png?fit=max&auto=format&n=n_48dzI5l_tB6XfZ&q=85&s=f912fb44a3682c547583773c5bb87a58" alt="Manage permission set assignments" className="mx-auto" width="1647" height="443" data-path="images/salesforce-flow-package-5.png" />

    <Info>
      If the flow runs automatically (because of a record change, not because someone clicks), assign the permission to the **user the flow runs as**, not just to administrators. It's the most common mistake in this part.
    </Info>
  </Step>
</Steps>

<div class="hr" />

## 4. Create the flow that launches the conversation

With the package installed and the permissions assigned, the Treble action is now available in the Salesforce **Flow Builder**.

The following example launches a WhatsApp conversation every time an account is created. The same structure works for any other trigger.

<Steps>
  <Step title="Go to Flows">
    In Setup, go to **Process Automation → Flows** and click **New Flow**.

    <img src="https://mintcdn.com/trebleai/n_48dzI5l_tB6XfZ/images/salesforce-flow-use-1.png?fit=max&auto=format&n=n_48dzI5l_tB6XfZ&q=85&s=b5f341bf12bae77c86be05e12762fee7" alt="Flows inside Process Automation" className="mx-auto" width="3024" height="1712" data-path="images/salesforce-flow-use-1.png" />
  </Step>

  <Step title="Choose the flow type">
    For it to trigger on its own when data changes, choose **Record-Triggered Flow**.

    <img src="https://mintcdn.com/trebleai/n_48dzI5l_tB6XfZ/images/salesforce-flow-use-2.png?fit=max&auto=format&n=n_48dzI5l_tB6XfZ&q=85&s=d6af420f59bd72b8ffe077addb3887f2" alt="Choose Record-Triggered Flow" className="mx-auto" width="3024" height="1712" data-path="images/salesforce-flow-use-2.png" />
  </Step>

  <Step title="Configure the trigger and enable the asynchronous path">
    Choose the object (in the example, `Account`), when it triggers (*A record is created*), and in **Optimize the Flow for** choose **Actions and Related Records**.

    <Warning>
      **This is the step that's most often forgotten.** Below, enable **Add Asynchronous Path**.

      Salesforce **doesn't allow** calling an external system from the normal path of a record-triggered flow. Without this path, the Treble action will fail.
    </Warning>

    <img src="https://mintcdn.com/trebleai/n_48dzI5l_tB6XfZ/images/salesforce-flow-use-3.png?fit=max&auto=format&n=n_48dzI5l_tB6XfZ&q=85&s=f5c06ba02076769b787d8dfe7b9a7a73" alt="The Add Asynchronous Path toggle" className="mx-auto" width="3020" height="1710" data-path="images/salesforce-flow-use-3.png" />

    When you enable it, the flow splits into two paths: **Run Immediately** and **Run Asynchronously**.

    <img src="https://mintcdn.com/trebleai/n_48dzI5l_tB6XfZ/images/salesforce-flow-use-4.png?fit=max&auto=format&n=n_48dzI5l_tB6XfZ&q=85&s=071bf911633c72828d522fc9e2ffa003" alt="The flow with the immediate and asynchronous paths" className="mx-auto" width="3020" height="1708" data-path="images/salesforce-flow-use-4.png" />

    <Check>
      Everything that calls Treble goes in the **Run Asynchronously** branch.
    </Check>
  </Step>

  <Step title="Optional: store the data you need in variables">
    If you want to have record data at hand, add an **Assignment** element in the asynchronous branch.

    <img src="https://mintcdn.com/trebleai/n_48dzI5l_tB6XfZ/images/salesforce-flow-use-5.png?fit=max&auto=format&n=n_48dzI5l_tB6XfZ&q=85&s=a91932c9592860f45b3322936c403471" alt="Assignment element storing the contact's name" className="mx-auto" width="1622" height="1460" data-path="images/salesforce-flow-use-5.png" />

    In the example, the name of the contact that triggered the flow is stored in a `contactname` variable. The same is done with the phone, which is the data the Treble action does need.
  </Step>

  <Step title="Add the Treble action">
    In the asynchronous branch, click **+** and choose **Action**.

    <img src="https://mintcdn.com/trebleai/n_48dzI5l_tB6XfZ/images/salesforce-flow-use-6.png?fit=max&auto=format&n=n_48dzI5l_tB6XfZ&q=85&s=0d6b1f587660ec0d405e747af48be962" alt="Add an element to the flow" width="420" className="mx-auto" data-path="images/salesforce-flow-use-6.png" />

    <img src="https://mintcdn.com/trebleai/n_48dzI5l_tB6XfZ/images/salesforce-flow-use-7.png?fit=max&auto=format&n=n_48dzI5l_tB6XfZ&q=85&s=18a5577cf6494caa307fa4ab2aae1495" alt="Choose the Action element" width="420" className="mx-auto" data-path="images/salesforce-flow-use-7.png" />

    Search for `treble` and select **Deploy Treble Conversation**.

    <img src="https://mintcdn.com/trebleai/n_48dzI5l_tB6XfZ/images/salesforce-flow-use-8.png?fit=max&auto=format&n=n_48dzI5l_tB6XfZ&q=85&s=fbe50a121918d720932a47f2e91b1a06" alt="Search for and choose the Deploy Treble Conversation action" className="mx-auto" width="3024" height="1708" data-path="images/salesforce-flow-use-8.png" />

    <Info>
      If it doesn't appear, it's an installation or permissions problem, not a flow problem. Check [common issues](#common-issues).
    </Info>
  </Step>

  <Step title="Fill in the parameters">
    <img src="https://mintcdn.com/trebleai/n_48dzI5l_tB6XfZ/images/salesforce-flow-use-9.png?fit=max&auto=format&n=n_48dzI5l_tB6XfZ&q=85&s=a018bbf02663c91c3803fde67c9b92d9" alt="conversationId and phoneNumber parameters" className="mx-auto" width="1380" height="1488" data-path="images/salesforce-flow-use-9.png" />

    <img src="https://mintcdn.com/trebleai/n_48dzI5l_tB6XfZ/images/salesforce-flow-use-10.png?fit=max&auto=format&n=n_48dzI5l_tB6XfZ&q=85&s=c8d1a5c5cd490da0f9d9fcc9df30f8fd" alt="Optional deploymentPhone parameter and the result" className="mx-auto" width="1338" height="434" data-path="images/salesforce-flow-use-10.png" />

    | Parameter | Required? | What goes here |
    | - | - | - |
    | **conversationId** | Yes | The Id of the Treble campaign you want to launch |
    | **phoneNumber** | Yes | The destination mobile number, usually taken from the record that triggered the flow |
    | **deploymentPhone** | No | The Treble number you want to send from. Only useful if you have several; leave it off otherwise |

    <Info>
      `deploymentPhone` comes disabled ("Not Included"). Enable it only if you're going to use it.
    </Info>
  </Step>

  <Step title="Save and activate">
    Click **Save** and then **Activate**. A flow that's saved but not activated doesn't run.
  </Step>
</Steps>

<div class="hr" />

## What the action does under the hood

Two things are worth knowing, because they define what can and can't be done.

<AccordionGroup>
  <Accordion title="The result is text, not a yes or no">
    The action returns a single output, `result`, with a text:

    ```
    Success for conversation <id> and phoneNumber <numero>. Response: ...
    ```

    or, when something fails:

    ```
    Error: 401 Unauthorized
    ```

    If you want the flow to react to the failure —send an email, mark a field— you have to add a **Decision** element that evaluates that text, for example checking whether it **starts with** `Error`. There's no separate success or failure field.
  </Accordion>

  <Accordion title="Template variables can't be sent from the flow">
    The action sends Treble **the destination number and which campaign to launch**, and nothing else.

    That means **you can't pass values from the Salesforce record as WhatsApp template variables** from this flow. Message personalization has to be handled on the Treble side: the campaign can read Salesforce data with the [CRM blocks](/en/docs/integrations/salesforce/blocks/crm-variable-assignment) once the conversation has started.

    It's the most surprising limitation of this package, and it's worth being clear about it before designing the automation.
  </Accordion>

  <Accordion title="It works with several records at once">
    The action accepts batches, so it works the same in a flow that processes one record or many.
  </Accordion>
</AccordionGroup>

<div class="hr" />

Under the hood, the action calls Treble's **deployment** endpoint, the same one used to launch campaigns via API:

<a class="article-link" href="/en/api-reference/endpoints/deploy"><p>Deployment endpoint</p><Icon icon="arrow-up-right-from-square" iconType="solid" /></a>

<Note>
  **If you have two Treble accounts connected to the same Salesforce**, you need to configure the package **twice**, each with its own API key. The deployments of the two accounts can't be unified in a single configuration.
</Note>

<div class="hr" />

## Common issues

<AccordionGroup>
  <Accordion title="The deployment fails with a 401 error">
    It's the classic symptom of an incomplete configuration: the package was installed, but the `Authorization` header or the permission set aren't set up correctly.

    Our engineering team's recommendation in these cases is to **uninstall the package and reinstall it** following this guide step by step, instead of trying to fix the existing configuration.
  </Accordion>

  <Accordion title="I installed the package but the Treble credential doesn't appear">
    This happens when the installation only partially completed, even if the Salesforce confirmation email arrived.

    Check in *Setup → Named Credentials*, **External Credentials** tab, that `treble_api_external_credential` exists. If it's not there, uninstall the package and reinstall it.
  </Accordion>

  <Accordion title="The flow fails with an authentication or credential error">
    The two usual causes:

    1. **The `Authorization` header hasn't been created**, or the API key is incomplete.
    2. **The user running the flow doesn't have the** `treble_api_permission` **permission set assigned**.
  </Accordion>

  <Accordion title="I don't see the Treble action in Flow Builder">
    Search for `treble` in the action search box: **Deploy Treble Conversation** should appear, in the **Treble** category.

    If it's not there, confirm that the package installation completed correctly and that your user is within the scope you chose when installing (admins, all users, or specific profiles).
  </Accordion>

  <Accordion title="The flow can't be saved because the action makes an external call">
    You need to enable the **asynchronous path**. Salesforce doesn't allow calling an external system from the immediate path of a record-triggered flow.

    Open *Configure Start*, enable **Add Asynchronous Path**, and move the Treble action to the **Run Asynchronously** branch.
  </Accordion>

  <Accordion title="It works for me but not when the flow runs on its own">
    It's the permission case: an automatic flow runs as a different user than you. Assign the permission set to that user.
  </Accordion>
</AccordionGroup>

<div class="hr" />

## Next steps

<CardGroup cols={2}>
  <Card title="WhatsApp inside Salesforce" icon="window-maximize" href="/en/docs/integrations/salesforce/embed/custom-tab">
    So advisors can reply without leaving the CRM.
  </Card>

  <Card title="Marketing Cloud" icon="bullhorn" href="/en/docs/integrations/salesforce/embed/marketing-cloud">
    Launch conversations from Marketing Cloud.
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.