@frogbotai/piece-salesforce works with Salesforce through its REST API v68.0. Imports page through any object, standard or custom, and use Bulk API 2.0 for large ones; agents create, update and find records, cases, contacts, leads, opportunities and tasks, and run reports; triggers poll for new and changed records and receive Outbound Messages.
Connect Salesforce
See factory options for the shared options.
Production, sandboxes and My Domain
createSalesforce signs in at login.salesforce.com. For a sandbox or a My Domain, define the piece for that login host with defineSalesforce:
One definition signs in at one host. To connect production and a sandbox side by side, use two definitions with different slugs.
Create an External Client App
Salesforce no longer lets you create new Connected Apps, so use an External Client App:- In Setup, open External Client App Manager and choose New External Client App.
- Under API (Enable OAuth Settings), turn on OAuth, and add the instance’s callback URL:
https://your-app.example.com/api/connections/salesforce/callback(use your instance slug). - Add the OAuth scopes Manage user data via APIs (
api), Perform requests at any time (refresh_token,offline_access) and Access the identity URL service (id). - Turn on Require Proof Key for Code Exchange (PKCE) and leave the flow as the authorization code flow.
- Save, then copy the Consumer Key and Consumer Secret into
oauth.
instance_url, and every call goes to <instance_url>/services/data/v68.0. A path outside /services/data/, including a nextRecordsUrl, is refused before any request, so the token never goes anywhere else.
Salesforce’s sign-in reply doesn’t say when the token expires: it lasts until the org’s session timeout, 15 minutes at the shortest. FrogBot treats every token as 15 minutes old at most and refreshes it after that, so connections keep working whatever the org’s setting.
Import an org
Reads go one page per call, so a job can drive a large import a step at a time:
Build the field list from
describeObject and name the fields in the query: FIELDS(ALL) only works with LIMIT 200 and not at all in Bulk queries. Lookup fields such as AccountId, WhoId, WhatId and OwnerId keep the links between records.
Use a Bulk query job for objects over about 2,000 records. Salesforce runs it in the background, and it uses far fewer API calls.
- Bulk queries don’t support
FIELDS(),OFFSET,GROUP BY, aggregates, or parent-to-child subqueries. Child-to-parent lookups such asAccount.Namework. - The piece never waits on a job. Check it with
getQueryJobfrom a later job step.
Actions
Errors keep Salesforce’s
errorCode, message and HTTP status, as a SalesforceError.
Triggers
Polling
The polling triggers run every 5 minutes by default (see polling). The first poll only records the time and emits nothing. Each poll reads up to 200 records, ordered by time and thenId, and the next poll continues after the last one, so records sharing a timestamp and backlogs of any size come through once each.
Outbound Messages
newOutboundMessage emits changes as soon as Salesforce sends them, without waiting for a poll. The app needs a public serverURL (see Triggers).
- Mount the trigger and copy its subscription’s webhook URL,
/api/webhooks/<instance-slug>/<subscription-id>. - In Salesforce Setup, create an Outbound Message for the object, with that URL as the Endpoint URL and the fields to send.
- Send it from a record-triggered Flow (or a workflow rule).