Skip to main content

An integration package connecting Salesforce and LangChain

Project description

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

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:

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:
poetry install
  1. Run tests:
make test
  1. Run linting:
make lint

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_salesforce-0.1.0.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

langchain_salesforce-0.1.0-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file langchain_salesforce-0.1.0.tar.gz.

File metadata

  • Download URL: langchain_salesforce-0.1.0.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.5 Darwin/23.4.0

File hashes

Hashes for langchain_salesforce-0.1.0.tar.gz
Algorithm Hash digest
SHA256 790879627825865dc79a235df5e38240621b7fa51d7264f2cde19a0535780d27
MD5 2a787cf75151947abf99e19ae27f1b36
BLAKE2b-256 6ff99380f0a5fd58d8a2be4d08f8e299e39b8b8ea22dfe1a751687c87f88f2c3

See more details on using hashes here.

File details

Details for the file langchain_salesforce-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_salesforce-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0cc3bd8ec18cee591855d023b04693cd0636483badce20a87b054450e931b8d1
MD5 f29f5cba3e9147ddafc100d6d0e2e928
BLAKE2b-256 a9fbf1a1080ceff8c430b3d3ae3504c0127884b74885ca38739ec23d0f34967c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page