In this guide, we will walk through the essential steps required to build a Salesforce integration using the Cobalt platform. This process involves three major steps i.e. User Authentication with Salesforce, Creating Workflows and Using workflows for users.

Authenticating with Salesforce integration

To get started, first you need to enable the Salesforce integration in your account and also setup some basic processes.

1

Enable the Salesforce App

Step 1: Enable the Salesforce App

After setting up your account, the next step is to enable the Salesforce app in your Cobalt account.

Apps cannot be enabled using the API. You will need to enable the app through the UI.

To enable the Salesforce app:

Navigate to Apps in Cobalt and search for Salesforce and enable the app by clicking on the Go Live button in the top right corner.

Now, go to Settings and provide the Client ID and Client Secret of your Salesforce OAuth app and click on Save.

Follow the steps given here to get your credentials.

Once the app is enabled, you can proceed to create and manage workflows and linked accounts associated with Salesforce.

2

Create a Linked Account

Step 2: Create a Linked Account

A Linked Account in Cobalt represents the end-users or customers who will use the integration through the platform. Each Linked Account requires a unique linked_account_id, which typically corresponds to an ID from your internal data model (e.g., a user or account ID).

Learn more about Linked Accounts here.

To upsert (create or update) a Linked Account, use the following API call:

ParamRequiredTypeDescription
linked_account_idMandatoryStringUnique customer identifier
nameOptionalStringName of the customer

You can check the Linked Accounts in your Cobalt account by navigating to the Linked Accounts section in the side menu.

Once the Linked Account is successfully created or updated, it will be ready for authentication in the next step.

3

Generate Session Token for your Linked Account

Step 3: Generate Token

After creating a Linked Account, the next step is to generate a session token. Session tokens help protect your Cobalt API key and manage end-customer tokens more securely.

To create a session token, use the following API call:

This session token will be included in subsequent requests to Cobalt APIs to authenticate and authorize the actions.

4

Open Hosted Portal Auth Flow

Step 4: Open Hosted Portal Auth Flow

Next, you will need to generate a Hosted URL that your users will use to authenticate with Salesforce. Cobalt securely stores the credentials and handles API calls on behalf of your users.

Use the following API call to generate the Hosted URL:

The response will return a Hosted URL that your users can visit to authenticate and connect their Salesforce accounts.

Hosted Portal is a no-code solution provided by Cobalt that removes the need to build your own UI for handling integration authentication and configuration.

5

Authenticate Using Hosted Portal

Step 5: Perform OAuth Authentication

Visit the Hosted URL provided in the API response. The Hosted Portal will display all the integrations you have enabled, including Salesforce.

To authenticate:

  • Navigate to the Salesforce integration in the portal.
  • Click Connect to begin the authentication process and allow consent to permissions requested.
  • After completing the flow, you will be redirected back to the Hosted Portal with a confirmation that the account is successfully connected.

You have successfully authenticated with Salesforce integration.

The next step is to create workflows for your use-case.

Creating Workflows in Salesforce

There are 3 major categories of workflows that you can create in any integration.

Data Import from Salesforce

Sync data from Salesforce to your system.

Push Data to Salesforce

Create data on Salesforce from your system.

2-way sync between Salesforce and you

Keep the data between Salesforce and your system in sync.

Let’s look at a sample workflow for each case.

Data Import from Salesforce

Consider a use-case where you want to sync all the opportunities present in Salesforce to your system.

In the Salesforce integration, go to Workflows and create a new workflow by clicking on +Add Workflow button and name it as Sync Opportunities.

Push Data to Salesforce

Consider a use-case where you want to create a contact present in your system to Salesforce.

This workflow will be fired when you send an Event with the payload of the contact to be added.

In the Salesforce integration, go to Workflows and create a new workflow by clicking on +Add Workflow button and name it as Create New Contact.

2-way sync between Salesforce and you (Webhooks)

For bi-directional sync, usually three workflows are required:

  • Workflow for Initial sync where all the records are fetched from Salesforce. This is the same workflow as Data Import workflow that we created here.

  • Workflow to push record in Salesforce when a new record is created on your platform.

    We created this workflow of Push Data here.

  • Workflow to update records in your system whenever a contact gets created or updated in Salesforce.

You have successfully created the workflows for your use case.

Next step is to enable and execute those workflows for your Linked Accounts.

Executing the Workflows

To run these workflows for your users or Linked Accounts, you need to do the following steps:

1

Create Config for Linked Account

Config is a customization that you store for each integration of your end-customers.

Create Config

You can create config for the Linked Account through the Cobalt Connect SDKs or using the APIs.

You can use the .config() method or the Create Config API which returns the specified config or creates one if it doesn’t exist for the Linked Account.

Make a request with the Application Slug and linked_account_id as mandatory fields for it. You can request in the following way:

It will return information about config of the application for the Linked Account and provides you with all the published workflows and settings input for the user required to execute the workflow.

Response
{
	"slug": "salesforce",
	"config_id": "OPTIONAL_ID_FOR_THIS_CONFIG",
	"fields": [],
	"workflows": [
		{
			"id": "64d1fac58716dc5065127ffe",
			"name": "Sync Opportunities",
			"description": "",
			"enabled": false,
			"fields": []
		}
	],
	"field_errors": []
}
2

Enable Workflow

Now you need to enable the workflow for your Linked account. You can either ask the user to enable them or you can do so for them by using the Update Config API or .updateconfig() method.

Make the following request:

In response, you get the updated config information for the application.

3

Third Step

Once the required workflows are enabled, you need to fire event to start execution. You can use the Trigger Event for app API with the following request:

cURL
curl --request POST \
--url https://api.gocobalt.io/api/v2/public/event/:slug \
--header 'Content-Type: application/json' \
--header 'linked_account_id: <linked_account_id>' \
--header 'x-api-key: <api-key>' \
--data '{
"event": "<string>",
"payload": {}
}'
4

Check Execution Logs

Once the workflow execution has been fired, you can check the Logs of the workflow here.

Learn more about logs and observability here.

Congratulations!!

You have successfully created a Salesforce integration and executed it for your users.