Prerequisites
uv pip install -U simple-salesforce
export SALESFORCE_USERNAME="you@example.com"
export SALESFORCE_PASSWORD="your-password"
export SALESFORCE_SECURITY_TOKEN="token-from-email"
export SALESFORCE_DOMAIN="login"
Example
cookbook/91_tools/salesforce_tools.py
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.salesforce import SalesforceTools
# Read-only agent (default)
read_only_agent = Agent(
name="Salesforce Explorer",
model=OpenAIChat(id="gpt-4o"),
tools=[SalesforceTools()],
instructions=[
"Use describe_object to understand available fields before building queries.",
"Use SOQL for precise structured queries, SOSL for full-text search across objects.",
],
markdown=True,
)
# Full CRM agent with write operations enabled
full_crm_agent = Agent(
name="Salesforce CRM Agent",
model=OpenAIChat(id="gpt-4o"),
tools=[
SalesforceTools(
enable_create_record=True,
enable_update_record=True,
enable_delete_record=True,
)
],
instructions=[
"Always use describe_object to check required fields before creating records.",
"Confirm with the user before deleting any records.",
],
markdown=True,
)
if __name__ == "__main__":
# Explore available objects
read_only_agent.print_response(
"List the queryable Salesforce objects in this org",
stream=True,
)
# Query accounts
read_only_agent.print_response(
"Find the top 5 accounts by name using SOQL",
stream=True,
)
# Describe an object's schema
read_only_agent.print_response(
"Describe the Contact object. What fields are required for creating a new contact?",
stream=True,
)
# Search across objects
read_only_agent.print_response(
"Search for anything related to 'United' across all objects",
stream=True,
)
Run the Example
git clone https://github.com/agno-agi/agno.git
cd agno/cookbook/91_tools
# Create and activate virtual environment
./scripts/demo_setup.sh
source .venvs/demo/bin/activate
python salesforce_tools.py