Trigger a Salesforce Flow
Overview
Talkdesk provides an out-of-the-box Salesforce Connection that covers a multitude of use cases.
Salesforce, however, provides many other capabilities that are not targeted by this integration. For these cases, you may want to build a custom integration with Salesforce using Talkdesk Connections™ that allows you, for example, to trigger Salesforce lightning flows.
Required Background Knowledge
- A Salesforce account/instance.
- An auto launched Salesforce Flow (for the use case presented in this tutorial; you can always use the learnings here regarding how to set up a Salesforce Connection to access any other Salesforce API).
- Because OAuth2 Authentication Code Flow doesn’t currently work in Talkdesk Workspace, make sure the Talkdesk user that is setting up the Connection does not open Workspace by default. If you are currently on Talkdesk Workspace, go to Admin > Agents, click the relevant user, find the login part on Talkdesk Workspace section, then enable the option Activate Talkdesk Workspace as the default login experience, and click Save (Figure 1 - right corner, bottom).
![1 - talkdesk classic.png 1756](https://files.readme.io/a030ea9-1_-_talkdesk_classic.png)
Figure 1 - Login on Talkdesk Workspace
Implementation Steps
1 - Create the Salesforce connected app
2 - Create a Salesforce Connection
3 - Create an Action to trigger a Salesforce flow
4 - Create an automation to trigger a Salesforce flow
1 - Create a New Salesforce Connected App
The Salesforce Connected app allows you to obtain credentials to build an integration from another system with Salesforce. You’ll be able to use these credentials to create the Connection in the step 2 of this page. Let's start!
1 - Login to your Salesforce account.
2 - Create a New Connected App (via Build > Create > Apps - Figure 2 - left corner, bottom).
![2 - salesforce connected app.png 2300](https://files.readme.io/4abb16d-2_-_salesforce_connected_app.png)
Figure 2 - Creating a new Salesforce Connected app
3 - Add a Connected App Name, API Name and Contact Email (Figure 2 - top).
4 - Under API (Enable OAuth Settings), check the box for Enable OAuth Settings (Figure 2 - center).
5 - On the Callback URL, add the Talkdesk callback URL according to the region of the Talkdesk instance you are setting up your Connection at (Figure 2 - center). The Talkdesk URLs are:
- USA:
https://api.talkdeskapp.com/external-credentials/oauth2/callback
- Europe:
https://api.talkdeskapp.eu/external-credentials/oauth2/callback
- Canada:
https://api.talkdeskca.com/external-credentials/oauth2/callback
6 - Save the app configuration (Figure 2 - Save button, top).
After saving the settings, you have to wait a bit for them to be effective.
2 - Create a Salesforce Connection
After creating the Salesforce Connected App, the second step is to go to your Talkdesk instance, and create a Connection, using the Salesforce Connected App credentials. First, make sure you are logged in to your Talkdesk account.
1 - Go to Admin > Integrations and click the Add integration button (Figure 3 - top right corner).
![3 - integration list.png 2880](https://files.readme.io/d542dd0-3_-_integration_list.png)
Figure 3 - Creating a connection
2 - Go to Custom Integration – Powered by CONNECTIONS, and click the Add Integration button (Figure 4 - center).
![Figure 4 - Add Integration.png 2880](https://files.readme.io/5a7269f-Figure_4_-_Add_Integration.png)
Figure 4 - Add Integration
3 - Provide a Name and Description for this new integration (Figure 5 - left side).
![5 - create integration.png 2880](https://files.readme.io/1394598-5_-_create_integration.png)
Figure 5 - Adding a name and description
4 - Fill the Base path field with the URL of your Salesforce instance (e.g.: https://login.my.salesforce.com
) (Figure 5 - left corner, bottom).
5 - Click the Authentication type dropdown, and then select the OAuth2 Authorization Code Flow option (Figure 5 - bottom).
6 - Go back to your Connected Salesforce app settings within Salesforce and click Manage Consumer details (Figure 6 - center).
![6 - salesforce manage keys.png 1414](https://files.readme.io/d6e395d-6_-_salesforce_manage_keys.png)
Figure 6 - Manage Consumer details
7 - Salesforce will ask you to verify your identity. Insert the Verification Code and click Verify (Figure 7).
![7 - salesforce-verify.png 1414](https://files.readme.io/4764efd-7_-_salesforce-verify.png)
Figure 7 - Salesforce verify
8 - Once your code is verified, you will be redirected to a page containing your credentials. Copy the Consumer Key (Figure 8 - top).
![8 - salesforce consumer details.png 2280](https://files.readme.io/55c9ae8-8_-_salesforce_consumer_details.png)
8 - Salesforce consumer details
9 - Go back to your Talkdesk instance, and use the Consumer Key for the Client ID field of the Connection (Figure 9 - top).
![Figure 6 - Adding the Client Secret value.png 2880](https://files.readme.io/787e770-Figure_6_-_Adding_the_Client_Secret_value.png)
Figure 9 - Adding the Client Secret value
10 - Again, going back to Salesforce, copy the Consumer Secret (Figure 8 - top).
11 - Fill the Access Token URL and Authorization URL fields (Figure 9 - center) as specified by Salesforce:
- Access Token URL:
https://login.salesforce.com/services/oauth2/token
- Authorization URL:
https://login.salesforce.com/services/oauth2/authorize
Scopes
For the example in this tutorial (triggering a Salesforce Flow), no scopes are necessary. However, don’t forget to add them if the Salesforce APIs you want to use are scoped.
3 - Create an Action to Trigger a Salesforce Flow
In this use case, we’ll be creating an Action to trigger a Salesforce Flow.
To do this, we’ll go back to our Connection, and we will open the Actions tab and add a new Action that connects to the Salesforce endpoint for triggering flows. Let's start.
1 - On your Talkdesk instance, go to Admin > Integrations (Figure 10).
2 - Open the Salesforce Connection you created in step 2 of this page.
3 - Open the Actions tab (Figure 10 - left side).
4 - Click the Add action button (Figure 10 - right side).
![Figure 7 - Actions tab.png 2880](https://files.readme.io/4c290b8-Figure_7_-_Actions_tab.png)
Figure 10 - Actions tab
6 - Click the pencil button (Figure 10 - right side) to edit the Name and Description of the Action.
7 - Provide a Display Name for the parameter flow_name
and make sure that its Parameter type is String (Figure 11 - bottom)
![Figure 8 - URL settings.png 2880](https://files.readme.io/dc71837-Figure_8_-_URL_settings.png)
Figure 11 - URL settings
8 - In the Input JSON schema of the action, make sure you account for any input variables your flow may have. In our case, we set up the flow to have as input the Agent Name, resulting in the following JSON schema.
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"inputs": {
"title": "inputs",
"type": "array",
"items": [
{
"type": "object",
"properties": {
"AgentName": {
"title": "agent_name",
"type": "string"
}
},
"required": [
"AgentName"
]
}
]
}
},
"required": [
"inputs"
],
"additionalProperties": false
}
If you have output variables, make sure you set it up in your Output JSON schema (Figure 12 - left side). In our use case, the flow does not have any output variables, so we left this part empty.
You may want to set up a timeout different from the default. We’ve left the Action with the default timeout of 10 seconds (Figure 12 - left corner, bottom).
![12 - action timeout.png 2880](https://files.readme.io/e0aad55-12_-_action_timeout.png)
Figure 12 - Action Timeout
9 - Save your action as a Draft (Figure 13 - top left corner).
![13 - action publish.png 2880](https://files.readme.io/4426dc6-13_-_action_publish.png)
Figure 13 - Saving the action
10 - Go back to the Actions tab and test your Action (Figure 14 - top right corner).
11 - Given that everything works as expected, you can now publish your Action by clicking the Publish button (Figure 14 - top right corner).
![Figure 9 - Publishing an action.png 1414](https://files.readme.io/4cb4caf-Figure_9_-_Publishing_an_action.png)
Figure 14 - Publishing an action
4 - Create an Automation to Trigger a Salesforce Flow
We will now create an Automation to trigger a Salesforce Flow. To do this, we’ll go back to our Connection, open the Automations tab and call the Action that we’ve created in step 3 of this page, when a given Talkdesk event happens (in this case, when the agent status changes).
1 - On your Talkdesk instance, go to Admin > Integrations.
2 - Open the Salesforce Connection you created in step 2.
3 - Open the Automations tab (Figure 15 - top left corner) and the click the Create Automation button (Figure 15 - bottom center).
![14 - automation create.png 2880](https://files.readme.io/4f36261-14_-_automation_create.png)
Figure 15 - Automations tab
4 - Add the Automation name (Figure 16 - left side).
![Figure 11 - Editing an automation.png 2880](https://files.readme.io/a1fcb33-Figure_11_-_Editing_an_automation.png)
Figure 16 - Editing an automation
In our use case, we’ll trigger the Salesforce flow when an agent status changes.
5 - Fill the parameter of the Flow Name with the name of your Salesforce flow (Figure 17 - right side).
![Figure 12 - Configuring the action.png 2880](https://files.readme.io/1a1982c-Figure_12_-_Configuring_the_action.png)
Figure 17 - Configuring the action
6 - Under Inputs (Figure 18 - right side), click Configure.
![15 - configure json.png 2880](https://files.readme.io/7bb2c4c-15_-_configure_json.png)
Figure 18 - Configuring the action
7 - Add the following JSON to send the event’s agent name to your flow:
[
{
"AgentName": "{{agent.name}}"
}
]
To add the variable to the JSON, you can also drag the Agent name from the Agent Event fields on the left (Figure 18).
8 - Click Done (Figure 19 - right corner, bottom).
![16 - automation done.png 2880](https://files.readme.io/79ffb64-16_-_automation_done.png)
Figure 19 - Automation done
9 - Save your automation (Figure 20 - top right corner).
![17 - automation save.png 2880](https://files.readme.io/1616718-17_-_automation_save.png)
Figure 20 - Saving the automation
10 - Ensure that your automation status is enabled (Figure 21 - center).
![18 - automation enable.png 2880](https://files.readme.io/7a39665-18_-_automation_enable.png)
Figure 21 - Enabling automation status
You’ll now be calling a Salesforce flow every time a given agent status changes, for example, to keep a list within Salesforce of the agents that were active on a given day.
You can adapt this example to pass other variables and trigger the flow upon different Talkdesk events.
Additional Resources
- Salesforce flow documentation
- Salesforce Connected App documentation
- Talkdesk Connections
- OAuth2 Authorization Code Flow
- Talkdesk Knowledge Base: Creating a Connection, Creating an Action, Creating an Automation
Troubleshooting
If you have questions or technical issues, please open a ticket using this form.
Updated over 1 year ago