Salesforce
Integrate Stack AI with Salesforce for smarter sales workflows. Automate tasks, capture leads, and enhance CRM functionality with AI-powered insights.

The Salesforce Node allows you to connect directly to your Salesforce CRM account and query structured sales and customer data. It supports SQL queries to retrieve contact, lead, opportunity, and account information, making it easier to automate workflows, analyze performance, or power downstream nodes like LLMs or VectorDBs.
Once connected, Stack AI can use this data to enhance sales processes, generate insights, and improve decision-making.
Setting Up A Credentials Connection
Obtain your login credentials:
Username: your Salesforce login name.
Password: your Salesforce account password.

After logging in, click on your profile picture on the upper right.

A dropdown menu will appear, click on Settings.

On the Settings page, on the left navigation, select Reset My Security Token.

Click on Reset Security Token.

On click, the new Security token will be sent to the email associated to your Salesforce account.

Finally, in the email, this will be the Security token that will be used for the connection.

Steps to connect:
Add the Salesforce node from the Apps section into your Stack AI project.

Select "Query Salesforce" as the Action.

Click on "Select a connection" or create a new connection with your credentials.

Choose the appropriate domain for your Salesforce environment:
DomainUse When"login" or left blank
Connecting to production or developer orgs
"test"
Connecting to a sandbox instance
mycustomdomain
Using a custom domain (recommended for SSO or OAuth setups)

Note that the Username for your API is different from the email address you used to sign up for Salesforce.
Enabling the "sandbox" toggle tells Stack AI to connect to your Salesforce sandbox environment instead of your main (production) Salesforce account.
Disabling the "sandbox" toggle means Stack AI will connect to your production Salesforce environment.
Add your Salesforce Schema in the configurations of the node to define which table you want to extract.
For example: TABLE Contact (Id TEXT, Name TEXT, Industry TEXT);

To list tables from your Salesforce account, you can run the included Python script below on your local machine.
Setting Up An OAuth2 Connector + Connection:
Navigate to Setup (the gear in the top right corner), enter
App Managerin the Quick Find box, and click New External Client App in the top right corner.

Name the app and fill out the required information.
Ensure you select Enable OAuth under Enable OAuth Settings.
Type in your callback url. It should be the base web URL followed by
/auth. For our Cloud offering, the URL ishttps://www.stackai.com/authAdd the permissions your client needs. At minimum, usually
Access and manage your data (api)andPerform requests on your behalf at any time (refresh_token, offline_access)are required.Under Flow Enablement, toggle on at least Enable Authorization Code Flow
Under Security, select Enable Refresh Token Rotation, this will allow us to keep your connection alive.
Click Create
Go to Settings of your created app. Under OAuth settings, go to Consumer Key and Secret.
Save the key and secret you see here.
Salesforce OAuth2 Connector
In StackAI, go to Connectors in Settings. Search for Salesforce, and create a new OAuth2 Connector. Enter the key and secret you got from Salesforce here and click Create.

To establish a connection, select the new Connector you created in any connection dialog window, you will be automatically redirected to sign in to Salesforce, or logged in automatically if you are signed in already.
Visual overview

Below are some examples of valid SQL queries for your Salesforce database, provided that it has been included in the Schema:
Available Actions
1. Salesforce Query
Purpose: Query Salesforce using plain English or SOQL.
Inputs:
sql_schema (required): The database schema (tables, columns, types, etc.).
query (required): Your question in plain English or a SOQL query.
2. Create Case
Purpose: Create a new case in Salesforce.
Inputs:
subject (required): The subject/title of the case.
status (optional): Status of the case (e.g., New, Working, Closed).
priority (optional): Priority level (e.g., High, Medium, Low).
origin (optional): Source of the case (e.g., Web, Phone, Email).
description (optional): Detailed description.
account_id (optional): Salesforce Account ID to associate.
contact_id (optional): Salesforce Contact ID to associate.
3. Update Case
Purpose: Update an existing case.
Inputs:
case_id (required): Salesforce Case ID to update.
subject (optional): New subject/title.
status (optional): New status.
priority (optional): New priority.
origin (optional): New origin/source.
description (optional): New description.
account_id (optional): New Account ID.
contact_id (optional): New Contact ID.
4. Delete Case
Purpose: Delete a case.
Inputs:
case_id (required): Salesforce Case ID to delete.
5. Create Opportunity
Purpose: Create a new opportunity.
Inputs:
name (required): Name of the opportunity.
stage_name (required): Sales stage (e.g., Prospecting, Closed Won).
close_date (required): Expected close date (YYYY-MM-DD).
amount (optional): Opportunity amount.
account_id (optional): Account ID to associate.
description (optional): Description.
6. Update Opportunity
Purpose: Update an existing opportunity.
Inputs:
opportunity_id (required): Salesforce Opportunity ID to update.
name (optional): New name.
stage_name (optional): New stage.
close_date (optional): New close date.
amount (optional): New amount.
description (optional): New description.
7. Delete Opportunity
Purpose: Delete an opportunity.
Inputs:
opportunity_id (required): Salesforce Opportunity ID to delete.
8. Create Contact
Purpose: Create a new contact.
Inputs:
last_name (required): Last name of the contact.
first_name (optional): First name.
email (optional): Email address.
phone (optional): Phone number.
account_id (optional): Account ID to associate.
title (optional): Job title.
9. Update Contact
Purpose: Update an existing contact.
Inputs:
contact_id (required): Salesforce Contact ID to update.
last_name (optional): New last name.
first_name (optional): New first name.
email (optional): New email.
phone (optional): New phone.
title (optional): New job title.
10. Delete Contact
Purpose: Delete a contact.
Inputs:
contact_id (required): Salesforce Contact ID to delete.
Here are the details for the Salesforce actions you requested, in your specified format:
11. Create Comment
Purpose: Add a new comment to a Salesforce record (such as a Case, Opportunity, etc.).
Inputs:
parent_id (required): The Salesforce ID of the parent record to associate the comment with (e.g., Case ID, Opportunity ID).
comment_body (required): The text content of the comment.
is_published (optional): Boolean indicating if the comment should be published and visible to customers (default: true).
12. Update Comment
Purpose: Update the content or visibility of an existing Salesforce comment.
Inputs:
comment_id (required): The Salesforce ID of the comment to update.
comment_body (optional): The updated text content of the comment.
is_published (optional): Boolean indicating if the comment should be published and visible to customers.
13. Delete Comment
Purpose: Remove a comment from Salesforce.
Inputs:
comment_id (required): The Salesforce ID of the comment to delete.
Last updated
Was this helpful?

