https://github.com/colesmcintosh/langchain-salesforce
Langchain integration for Salesforce CRM, providing tools for SOQL queries, object schema inspection, and CRUD operations through Langchain's framework
https://github.com/colesmcintosh/langchain-salesforce
ai ai-a crm integration langchain machine-learning python salesforce soql
Last synced: about 1 year ago
JSON representation
Langchain integration for Salesforce CRM, providing tools for SOQL queries, object schema inspection, and CRUD operations through Langchain's framework
- Host: GitHub
- URL: https://github.com/colesmcintosh/langchain-salesforce
- Owner: colesmcintosh
- License: mit
- Created: 2025-02-14T02:30:49.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-02T15:40:01.000Z (over 1 year ago)
- Last Synced: 2025-04-12T23:44:45.619Z (about 1 year ago)
- Topics: ai, ai-a, crm, integration, langchain, machine-learning, python, salesforce, soql
- Language: Python
- Homepage: https://pypi.org/project/langchain-salesforce/
- Size: 85 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# langchain-salesforce
This package contains the LangChain integration with Salesforce, providing tools to interact with Salesforce CRM data using LangChain's framework.
## Features
- Salesforce CRM integration with LangChain
- SOQL query execution
- Object schema inspection
- CRUD operations on Salesforce objects
- Comprehensive error handling
## Installation
```bash
pip install -U langchain-salesforce
```
## Configuration
Configure your Salesforce credentials by setting the following environment variables:
* `SALESFORCE_USERNAME` - Your Salesforce username
* `SALESFORCE_PASSWORD` - Your Salesforce password
* `SALESFORCE_SECURITY_TOKEN` - Your Salesforce security token
* `SALESFORCE_DOMAIN` - Your Salesforce domain (defaults to "login", use "test" for sandbox)
## Usage
The `SalesforceTool` class provides a comprehensive interface to interact with Salesforce CRM:
```python
from langchain_salesforce import SalesforceTool
# Initialize the tool
tool = SalesforceTool(
username="your-username",
password="your-password",
security_token="your-security-token",
domain="login" # or "test" for sandbox
)
# Query contacts
result = tool.run({
"operation": "query",
"query": "SELECT Id, Name, Email FROM Contact LIMIT 5"
})
# Get object schema
schema = tool.run({
"operation": "describe",
"object_name": "Account"
})
# Create new contact
new_contact = tool.run({
"operation": "create",
"object_name": "Contact",
"record_data": {"LastName": "Smith", "Email": "smith@example.com"}
})
# Update a contact
updated_contact = tool.run({
"operation": "update",
"object_name": "Contact",
"record_id": "003XXXXXXXXXXXXXXX",
"record_data": {"Email": "new.email@example.com"}
})
# Delete a contact
delete_result = tool.run({
"operation": "delete",
"object_name": "Contact",
"record_id": "003XXXXXXXXXXXXXXX"
})
# List available objects
objects = tool.run({
"operation": "list_objects"
})
```
## Supported Operations
- `query`: Execute SOQL queries
- `describe`: Get object schema information
- `list_objects`: List available Salesforce objects
- `create`: Create new records
- `update`: Update existing records
- `delete`: Delete records
## Development
To contribute to this project:
1. Clone the repository
2. Install dependencies with Poetry:
```bash
poetry install
```
3. Run tests:
```bash
make test
```
4. Run linting:
```bash
make lint
```
## License
This project is licensed under the MIT License - see the LICENSE file for details.