LangChain integration for Salesforce CRM. Query data with SOQL, inspect schemas, and manage records (CRUD) directly from your LangChain applications.
pip install -U langchain-salesforceSet these environment variables:
| Variable | Description |
|---|---|
SALESFORCE_USERNAME |
Your Salesforce username |
SALESFORCE_PASSWORD |
Your Salesforce password |
SALESFORCE_SECURITY_TOKEN |
Your Salesforce security token |
SALESFORCE_DOMAIN |
login (production) or test (sandbox). Default: login |
from langchain_salesforce import SalesforceTool
tool = SalesforceTool()
# Query contacts
result = tool.run({
"operation": "query",
"query": "SELECT Id, Name, Email FROM Contact LIMIT 5"
})| Operation | Description | Required Parameters |
|---|---|---|
query |
Execute SOQL queries | query |
describe |
Get object schema | object_name |
list_objects |
List all SObjects | — |
create |
Create a record | object_name, record_data |
update |
Update a record | object_name, record_id, record_data |
delete |
Delete a record | object_name, record_id |
get_field_metadata |
Get field details | object_name, field_name |
# Describe an object
tool.run({"operation": "describe", "object_name": "Account"})
# Create a record
tool.run({
"operation": "create",
"object_name": "Contact",
"record_data": {"LastName": "Doe", "Email": "doe@example.com"}
})
# Update a record
tool.run({
"operation": "update",
"object_name": "Contact",
"record_id": "003XXXXXXXXXXXXXXX",
"record_data": {"Email": "updated@example.com"}
})
# Delete a record
tool.run({"operation": "delete", "object_name": "Contact", "record_id": "003XXXXXXXXXXXXXXX"})
# Get field metadata
tool.run({"operation": "get_field_metadata", "object_name": "Contact", "field_name": "Email"})git clone https://github.com/colesmcintosh/langchain-salesforce.git
cd langchain-salesforce
uv sync --all-groups
make format # Format code
make lint # Run linters
make test # Run testsSee CONTRIBUTING.md for guidelines.
MIT License. See LICENSE.