Setu Recipes: reusable workflows across every app.Browse templates

Integrations / Salesforce

Salesforce

CRM: leads, contacts, accounts, opportunities and tasks, with SOQL and SOSL search. Works against the connected org's own Salesforce host (REST API v67.0).

10 actions OAuth 2 6 read3 write1 destructive Calls login.salesforce.com

Connect

TypeScript
const conn = await setu.connections.initiate({ userId: "user_1", toolkit: "salesforce" });
console.log(conn.connectUrl); // show this to your user
await conn.waitUntilActive();

Permissions requested

ScopeWhy it is requested
apiRead and write Salesforce records through the REST API
refresh_tokenStay connected without asking you to sign in again
openidIdentify the connected Salesforce user
emailShow which Salesforce user is connected, by email address

Actions

Create recordwritesalesforce.create_recordCreate a record of any object type from a map of field API names to values. Lead needs LastName and Company; Contact needs LastName; Account needs Name; Opportunity needs Name, StageName and CloseDate.

Needs scope: api

InputTypeDescription
sobjectstringRequiredAPI name of the object, e.g. Lead, Contact, Account, Opportunity, Task
fieldsobjectRequiredField values keyed by API name, e.g. {"LastName": "Smith", "Company": "Acme"}
TypeScript
await setu.execute({
  userId: "user_1",
  action: "salesforce.create_record",
  input: {
    "sobject": "<sobject>",
    "fields": {}
  },
});
Delete recorddestructivesalesforce.delete_recordDelete a record by object type and id. Salesforce moves it to the Recycle Bin, where an admin can restore it for a limited time.

Needs scope: api

InputTypeDescription
sobjectstringRequiredAPI name of the object, e.g. Lead, Contact, Task
idstringRequiredSalesforce record id
TypeScript
await setu.execute({
  userId: "user_1",
  action: "salesforce.delete_record",
  input: {
    "sobject": "<sobject>",
    "id": "<id>"
  },
  confirm: true,
});
Describe object fieldsreadsalesforce.describe_sobjectList the field API names, types and picklist-ness of an object, so you know what to put in a query or record. Use before writing to unfamiliar or custom objects.

Needs scope: api

InputTypeDescription
sobjectstringRequiredAPI name of the object, e.g. Lead, Opportunity, Invoice__c
TypeScript
await setu.execute({
  userId: "user_1",
  action: "salesforce.describe_sobject",
  input: {
    "sobject": "<sobject>"
  },
});
Get recordreadsalesforce.get_recordGet one record by object type and 15 or 18 character id (Lead, Contact, Account, Opportunity, Task or any custom object). Optionally limit the fields returned.

Needs scope: api

InputTypeDescription
sobjectstringRequiredAPI name of the object, e.g. Lead, Contact, Account, Opportunity, Task, or a custom object like Invoice__c
idstringRequiredSalesforce record id
fieldsarray of stringOptionalField API names to return, e.g. [Id, Name, Email]. Omit for all fields.
TypeScript
await setu.execute({
  userId: "user_1",
  action: "salesforce.get_record",
  input: {
    "sobject": "<sobject>",
    "id": "<id>"
  },
});
List objectsreadsalesforce.list_sobjectsList the API names of all objects (standard and custom) available in the connected org.

Needs scope: api

No input.

TypeScript
await setu.execute({
  userId: "user_1",
  action: "salesforce.list_sobjects",
  input: {},
});
Log a task or notewritesalesforce.log_taskCreate a Task (a logged call, email, follow-up or note) and optionally attach it to a person with WhoId (Lead or Contact id) and a record with WhatId (Account or Opportunity id).

Needs scope: api

InputTypeDescription
subjectstringRequiredTask subject line
descriptionstringOptionalLonger notes or call summary
statusstringOptionalTask status picklist value, e.g. Not Started, In Progress, Completed (org picklists may differ)
prioritystringOptionalTask priority picklist value, e.g. High, Normal, Low
due_datestringOptionalDue date, YYYY-MM-DD
who_idstringOptionalLead or Contact id the task is about
what_idstringOptionalAccount, Opportunity or other record id the task relates to
TypeScript
await setu.execute({
  userId: "user_1",
  action: "salesforce.log_task",
  input: {
    "subject": "<subject>"
  },
});
Run SOQL queryreadsalesforce.queryRun a SOQL query (for example SELECT Id, Name, Email FROM Contact WHERE LastName = 'Smith' LIMIT 10). Returns records plus nextRecordsUrl when more pages exist.

Needs scope: api

InputTypeDescription
qstringRequiredA complete SOQL statement. Field and object names are case-insensitive but conventionally PascalCase (Lead, Contact, Account, Opportunity, Task).
TypeScript
await setu.execute({
  userId: "user_1",
  action: "salesforce.query",
  input: {
    "q": "<q>"
  },
});
Get next page of query resultsreadsalesforce.query_moreFetch the next page of a SOQL query using the locator id from a previous result's nextRecordsUrl (the last path segment, such as 01gD0000002HU6KIAW-2000).

Needs scope: api

InputTypeDescription
locatorstringRequiredThe final path segment of nextRecordsUrl, e.g. 01gD0000002HU6KIAW-2000
TypeScript
await setu.execute({
  userId: "user_1",
  action: "salesforce.query_more",
  input: {
    "locator": "<locator>"
  },
});
Update recordwritesalesforce.update_recordUpdate fields on an existing record by object type and id. Only the fields you pass change. Returns no content on success.

Needs scope: api

InputTypeDescription
sobjectstringRequiredAPI name of the object, e.g. Lead, Contact, Account, Opportunity
idstringRequiredSalesforce record id
fieldsobjectRequiredField values to change keyed by API name, e.g. {"Status": "Working - Contacted"}
TypeScript
await setu.execute({
  userId: "user_1",
  action: "salesforce.update_record",
  input: {
    "sobject": "<sobject>",
    "id": "<id>",
    "fields": {}
  },
});