enhancementgood first issueintegrationnew-featurenew-integration
Métriques du dépôt
- Stars
- (1 930 étoiles)
- Métriques de merge PR
- (Merge moyen 3h 2m) (10 PRs mergées en 30 j)
Description
Description
Add Salesforce integration to sync CRM data including leads, contacts, accounts, opportunities, and activity into CORE.
Reference Implementations
Existing Integrations (use as templates)
integrations/github/- Similar webhook-driven event systemintegrations/linear/- Project management integrationintegrations/slack/- For messaging reference
Required Files Structure
integrations/salesforce/
├── src/
│ ├── index.ts # Main entry, OAuth spec
│ ├── schedule.ts # Sync logic
│ ├── utils.ts # Salesforce API utilities
│ ├── account-create.ts # OAuth setup
│ └── create-activity.ts # Activity formatting
├── package.json
├── tsup.config.ts
└── README.md
Salesforce API Integration
OAuth Setup
- Use OAuth 2.0 (Authorization Code Grant)
- Authorization URL:
https://login.salesforce.com/services/oauth2/authorize - Token URL:
https://login.salesforce.com/services/oauth2/token - Revoke URL:
https://login.salesforce.com/services/oauth2/revoke - Required scopes:
api- Access and manage data via APIsrefresh_token(oroffline_access) - Allow refresh tokens for offline accessid- Access identity URL servicechatter_api- Access Chatter REST API (optional)full- Full access to all data (alternative to granular scopes)
Base URL
https://{instance}.salesforce.com/services/data/v66.0(Spring '26 - latest)- Instance URL is returned in the OAuth token response
Key Endpoints
GET /services/data/- List available API versionsGET /services/data/v66.0/sobjects/- List all sObjectsGET /services/data/v66.0/sobjects/{sObject}/describe- Describe an sObjectGET /services/data/v66.0/sobjects/{sObject}/{id}- Get a recordPOST /services/data/v66.0/sobjects/{sObject}/- Create a recordPATCH /services/data/v66.0/sobjects/{sObject}/{id}- Update a recordDELETE /services/data/v66.0/sobjects/{sObject}/{id}- Delete a recordGET /services/data/v66.0/query/?q={SOQL}- Execute SOQL queryGET /services/data/v66.0/queryAll/?q={SOQL}- Query all (including deleted/archived)GET /services/data/v66.0/search/?q={SOSL}- Execute SOSL searchGET /services/data/v66.0/recent- Recently viewed recordsGET /services/data/v66.0/limits- API usage limitsGET /services/data/v66.0/sobjects/{sObject}/updated/?start={start}&end={end}- Get updated records in time rangeGET /services/data/v66.0/sobjects/{sObject}/deleted/?start={start}&end={end}- Get deleted records in time range
Key sObjects
Lead- Sales leadsContact- ContactsAccount- Companies/organizationsOpportunity- Deals/opportunitiesTask- Tasks and activitiesEvent- Calendar eventsCase- Support casesNote- Notes
Events to Track
-
Lead Events
- Lead created
- Lead updated (status change, assignment)
- Lead converted to opportunity
- Lead deleted
-
Contact/Account Events
- Contact created/updated/deleted
- Account created/updated/deleted
-
Opportunity Events
- Opportunity created
- Opportunity stage changed
- Opportunity won/lost
- Opportunity amount updated
- Opportunity deleted
-
Task/Activity Events
- Task created/completed
- Event created/updated
- Call logged
- Email logged
-
Case Events
- Case created
- Case status changed
- Case closed
Implementation Tasks
- Set up basic integration structure following
integrations/github/src/index.tspattern - Implement OAuth 2.0 flow in
account-create.ts(handle instance URL from token response) - Create Salesforce API utilities in
utils.tswith SOQL query builder - Implement sync logic in
schedule.tsusing updated/deleted record endpoints for incremental sync - Convert Salesforce records and events to CORE activity format
- Handle pagination for large query results (nextRecordsUrl)
- Add error handling and rate limiting
- Support Salesforce sandbox environments (
test.salesforce.com) - Create integration documentation
- Add to
integrations/README.md
Technical Notes
- Salesforce REST API v66.0 (Spring '26) is the latest version
- Instance URL varies per org (e.g.,
na1.salesforce.com,eu5.salesforce.com) - extracted from OAuth response - Use
updatedanddeletedendpoints for efficient incremental sync - SOQL supports complex queries with relationships (similar to SQL JOINs)
- Salesforce has strict API call limits based on org edition (e.g., 15,000/day for Enterprise)
- Sandbox environments use
test.salesforce.comfor OAuth instead oflogin.salesforce.com - Refresh tokens do not expire unless revoked
- Bulk API available for large data volumes (separate endpoint)
Resources
- Salesforce REST API Developer Guide (v66.0)
- Salesforce OAuth Authorization
- Salesforce OAuth Scopes
- Execute SOQL Queries
- Salesforce REST API PDF (v66.0, Spring '26)
Labels
enhancement, integration, new-feature