Getting Started
Integration Docs
- Asana Integration
- Box Integration
- ClickUp Integration
- GitHub Integration
- Gmail Integration
- Google Calendar Integration
- Google Sheets Integration
- HubSpot Integration
- Jira Integration
- Linear Integration
- Notion Integration
- Salesforce Integration
- Shopify Integration
- Slack Integration
- Stripe Integration
- Zendesk Integration
How-To Guides
Resources
Salesforce Integration
CRM and sales automation with Salesforce integration for CrewAI.
Overview
Enable your agents to manage customer relationships, sales processes, and data through Salesforce. Create and update records, manage leads and opportunities, execute SOQL queries, and streamline your CRM workflows with AI-powered automation.
Prerequisites
Before using the Salesforce integration, ensure you have:
- A CrewAI Enterprise account with an active subscription
- A Salesforce account with appropriate permissions
- Connected your Salesforce account through the Integrations page
Available Tools
Record Management
Description: Create a new Contact record in Salesforce.
Parameters:
FirstName
(string, optional): First NameLastName
(string, required): Last Name - This field is requiredaccountId
(string, optional): Account ID - The Account that the Contact belongs toEmail
(string, optional): Email addressTitle
(string, optional): Title of the contact, such as CEO or Vice PresidentDescription
(string, optional): A description of the ContactadditionalFields
(object, optional): Additional fields in JSON format for custom Contact fields
Description: Create a new Lead record in Salesforce.
Parameters:
FirstName
(string, optional): First NameLastName
(string, required): Last Name - This field is requiredCompany
(string, required): Company - This field is requiredEmail
(string, optional): Email addressPhone
(string, optional): Phone numberWebsite
(string, optional): Website URLTitle
(string, optional): Title of the contact, such as CEO or Vice PresidentStatus
(string, optional): Lead Status - Use Connect Portal Workflow Settings to select Lead StatusDescription
(string, optional): A description of the LeadadditionalFields
(object, optional): Additional fields in JSON format for custom Lead fields
Description: Create a new Opportunity record in Salesforce.
Parameters:
Name
(string, required): The Opportunity name - This field is requiredStageName
(string, optional): Opportunity Stage - Use Connect Portal Workflow Settings to select stageCloseDate
(string, optional): Close Date in YYYY-MM-DD format - Defaults to 30 days from current dateAccountId
(string, optional): The Account that the Opportunity belongs toAmount
(string, optional): Estimated total sale amountDescription
(string, optional): A description of the OpportunityOwnerId
(string, optional): The Salesforce user assigned to work on this OpportunityNextStep
(string, optional): Description of next task in closing OpportunityadditionalFields
(object, optional): Additional fields in JSON format for custom Opportunity fields
Description: Create a new Task record in Salesforce.
Parameters:
whatId
(string, optional): Related to ID - The ID of the Account or Opportunity this Task is related towhoId
(string, optional): Name ID - The ID of the Contact or Lead this Task is related tosubject
(string, required): Subject of the taskactivityDate
(string, optional): Activity Date in YYYY-MM-DD formatdescription
(string, optional): A description of the TasktaskSubtype
(string, required): Task Subtype - Options: task, email, listEmail, callStatus
(string, optional): Status - Options: Not Started, In Progress, CompletedownerId
(string, optional): Assigned To ID - The Salesforce user assigned to this TaskcallDurationInSeconds
(string, optional): Call Duration in secondsisReminderSet
(boolean, optional): Whether reminder is setreminderDateTime
(string, optional): Reminder Date/Time in ISO formatadditionalFields
(object, optional): Additional fields in JSON format for custom Task fields
Description: Create a new Account record in Salesforce.
Parameters:
Name
(string, required): The Account name - This field is requiredOwnerId
(string, optional): The Salesforce user assigned to this AccountWebsite
(string, optional): Website URLPhone
(string, optional): Phone numberDescription
(string, optional): Account descriptionadditionalFields
(object, optional): Additional fields in JSON format for custom Account fields
Description: Create a record of any object type in Salesforce.
Note: This is a flexible tool for creating records of custom or unknown object types.
Record Updates
Description: Update an existing Contact record in Salesforce.
Parameters:
recordId
(string, required): The ID of the record to updateFirstName
(string, optional): First NameLastName
(string, optional): Last NameaccountId
(string, optional): Account ID - The Account that the Contact belongs toEmail
(string, optional): Email addressTitle
(string, optional): Title of the contactDescription
(string, optional): A description of the ContactadditionalFields
(object, optional): Additional fields in JSON format for custom Contact fields
Description: Update an existing Lead record in Salesforce.
Parameters:
recordId
(string, required): The ID of the record to updateFirstName
(string, optional): First NameLastName
(string, optional): Last NameCompany
(string, optional): Company nameEmail
(string, optional): Email addressPhone
(string, optional): Phone numberWebsite
(string, optional): Website URLTitle
(string, optional): Title of the contactStatus
(string, optional): Lead StatusDescription
(string, optional): A description of the LeadadditionalFields
(object, optional): Additional fields in JSON format for custom Lead fields
Description: Update an existing Opportunity record in Salesforce.
Parameters:
recordId
(string, required): The ID of the record to updateName
(string, optional): The Opportunity nameStageName
(string, optional): Opportunity StageCloseDate
(string, optional): Close Date in YYYY-MM-DD formatAccountId
(string, optional): The Account that the Opportunity belongs toAmount
(string, optional): Estimated total sale amountDescription
(string, optional): A description of the OpportunityOwnerId
(string, optional): The Salesforce user assigned to work on this OpportunityNextStep
(string, optional): Description of next task in closing OpportunityadditionalFields
(object, optional): Additional fields in JSON format for custom Opportunity fields
Description: Update an existing Task record in Salesforce.
Parameters:
recordId
(string, required): The ID of the record to updatewhatId
(string, optional): Related to ID - The ID of the Account or Opportunity this Task is related towhoId
(string, optional): Name ID - The ID of the Contact or Lead this Task is related tosubject
(string, optional): Subject of the taskactivityDate
(string, optional): Activity Date in YYYY-MM-DD formatdescription
(string, optional): A description of the TaskStatus
(string, optional): Status - Options: Not Started, In Progress, CompletedownerId
(string, optional): Assigned To ID - The Salesforce user assigned to this TaskcallDurationInSeconds
(string, optional): Call Duration in secondsisReminderSet
(boolean, optional): Whether reminder is setreminderDateTime
(string, optional): Reminder Date/Time in ISO formatadditionalFields
(object, optional): Additional fields in JSON format for custom Task fields
Description: Update an existing Account record in Salesforce.
Parameters:
recordId
(string, required): The ID of the record to updateName
(string, optional): The Account nameOwnerId
(string, optional): The Salesforce user assigned to this AccountWebsite
(string, optional): Website URLPhone
(string, optional): Phone numberDescription
(string, optional): Account descriptionadditionalFields
(object, optional): Additional fields in JSON format for custom Account fields
Description: Update a record of any object type in Salesforce.
Note: This is a flexible tool for updating records of custom or unknown object types.
Record Retrieval
Description: Get a Contact record by its ID.
Parameters:
recordId
(string, required): Record ID of the Contact
Description: Get a Lead record by its ID.
Parameters:
recordId
(string, required): Record ID of the Lead
Description: Get an Opportunity record by its ID.
Parameters:
recordId
(string, required): Record ID of the Opportunity
Description: Get a Task record by its ID.
Parameters:
recordId
(string, required): Record ID of the Task
Description: Get an Account record by its ID.
Parameters:
recordId
(string, required): Record ID of the Account
Description: Get a record of any object type by its ID.
Parameters:
recordType
(string, required): Record Type (e.g., “CustomObject__c”)recordId
(string, required): Record ID
Record Search
Description: Search for Contact records with advanced filtering.
Parameters:
filterFormula
(object, optional): Advanced filter in disjunctive normal form with field-specific operatorssortBy
(string, optional): Sort field (e.g., “CreatedDate”)sortDirection
(string, optional): Sort direction - Options: ASC, DESCincludeAllFields
(boolean, optional): Include all fields in resultspaginationParameters
(object, optional): Pagination settings with pageCursor
Description: Search for Lead records with advanced filtering.
Parameters:
filterFormula
(object, optional): Advanced filter in disjunctive normal form with field-specific operatorssortBy
(string, optional): Sort field (e.g., “CreatedDate”)sortDirection
(string, optional): Sort direction - Options: ASC, DESCincludeAllFields
(boolean, optional): Include all fields in resultspaginationParameters
(object, optional): Pagination settings with pageCursor
Description: Search for Opportunity records with advanced filtering.
Parameters:
filterFormula
(object, optional): Advanced filter in disjunctive normal form with field-specific operatorssortBy
(string, optional): Sort field (e.g., “CreatedDate”)sortDirection
(string, optional): Sort direction - Options: ASC, DESCincludeAllFields
(boolean, optional): Include all fields in resultspaginationParameters
(object, optional): Pagination settings with pageCursor
Description: Search for Task records with advanced filtering.
Parameters:
filterFormula
(object, optional): Advanced filter in disjunctive normal form with field-specific operatorssortBy
(string, optional): Sort field (e.g., “CreatedDate”)sortDirection
(string, optional): Sort direction - Options: ASC, DESCincludeAllFields
(boolean, optional): Include all fields in resultspaginationParameters
(object, optional): Pagination settings with pageCursor
Description: Search for Account records with advanced filtering.
Parameters:
filterFormula
(object, optional): Advanced filter in disjunctive normal form with field-specific operatorssortBy
(string, optional): Sort field (e.g., “CreatedDate”)sortDirection
(string, optional): Sort direction - Options: ASC, DESCincludeAllFields
(boolean, optional): Include all fields in resultspaginationParameters
(object, optional): Pagination settings with pageCursor
Description: Search for records of any object type.
Parameters:
recordType
(string, required): Record Type to searchfilterFormula
(string, optional): Filter search criteriaincludeAllFields
(boolean, optional): Include all fields in resultspaginationParameters
(object, optional): Pagination settings with pageCursor
List View Retrieval
Description: Get Contact records from a specific List View.
Parameters:
listViewId
(string, required): List View IDpaginationParameters
(object, optional): Pagination settings with pageCursor
Description: Get Lead records from a specific List View.
Parameters:
listViewId
(string, required): List View IDpaginationParameters
(object, optional): Pagination settings with pageCursor
Description: Get Opportunity records from a specific List View.
Parameters:
listViewId
(string, required): List View IDpaginationParameters
(object, optional): Pagination settings with pageCursor
Description: Get Task records from a specific List View.
Parameters:
listViewId
(string, required): List View IDpaginationParameters
(object, optional): Pagination settings with pageCursor
Description: Get Account records from a specific List View.
Parameters:
listViewId
(string, required): List View IDpaginationParameters
(object, optional): Pagination settings with pageCursor
Description: Get records of any object type from a specific List View.
Parameters:
recordType
(string, required): Record TypelistViewId
(string, required): List View IDpaginationParameters
(object, optional): Pagination settings with pageCursor
Custom Fields
Description: Deploy custom fields for Contact objects.
Parameters:
label
(string, required): Field Label for displays and internal referencetype
(string, required): Field Type - Options: Checkbox, Currency, Date, Email, Number, Percent, Phone, Picklist, MultiselectPicklist, Text, TextArea, LongTextArea, Html, Time, UrldefaultCheckboxValue
(boolean, optional): Default value for checkbox fieldslength
(string, required): Length for numeric/text fieldsdecimalPlace
(string, required): Decimal places for numeric fieldspickListValues
(string, required): Values for picklist fields (separated by new lines)visibleLines
(string, required): Visible lines for multiselect/text area fieldsdescription
(string, optional): Field descriptionhelperText
(string, optional): Helper text shown on hoverdefaultFieldValue
(string, optional): Default field value
Description: Deploy custom fields for Lead objects.
Parameters:
label
(string, required): Field Label for displays and internal referencetype
(string, required): Field Type - Options: Checkbox, Currency, Date, Email, Number, Percent, Phone, Picklist, MultiselectPicklist, Text, TextArea, LongTextArea, Html, Time, UrldefaultCheckboxValue
(boolean, optional): Default value for checkbox fieldslength
(string, required): Length for numeric/text fieldsdecimalPlace
(string, required): Decimal places for numeric fieldspickListValues
(string, required): Values for picklist fields (separated by new lines)visibleLines
(string, required): Visible lines for multiselect/text area fieldsdescription
(string, optional): Field descriptionhelperText
(string, optional): Helper text shown on hoverdefaultFieldValue
(string, optional): Default field value
Description: Deploy custom fields for Opportunity objects.
Parameters:
label
(string, required): Field Label for displays and internal referencetype
(string, required): Field Type - Options: Checkbox, Currency, Date, Email, Number, Percent, Phone, Picklist, MultiselectPicklist, Text, TextArea, LongTextArea, Html, Time, UrldefaultCheckboxValue
(boolean, optional): Default value for checkbox fieldslength
(string, required): Length for numeric/text fieldsdecimalPlace
(string, required): Decimal places for numeric fieldspickListValues
(string, required): Values for picklist fields (separated by new lines)visibleLines
(string, required): Visible lines for multiselect/text area fieldsdescription
(string, optional): Field descriptionhelperText
(string, optional): Helper text shown on hoverdefaultFieldValue
(string, optional): Default field value
Description: Deploy custom fields for Task objects.
Parameters:
label
(string, required): Field Label for displays and internal referencetype
(string, required): Field Type - Options: Checkbox, Currency, Date, Email, Number, Percent, Phone, Picklist, MultiselectPicklist, Text, TextArea, Time, UrldefaultCheckboxValue
(boolean, optional): Default value for checkbox fieldslength
(string, required): Length for numeric/text fieldsdecimalPlace
(string, required): Decimal places for numeric fieldspickListValues
(string, required): Values for picklist fields (separated by new lines)visibleLines
(string, required): Visible lines for multiselect fieldsdescription
(string, optional): Field descriptionhelperText
(string, optional): Helper text shown on hoverdefaultFieldValue
(string, optional): Default field value
Description: Deploy custom fields for Account objects.
Parameters:
label
(string, required): Field Label for displays and internal referencetype
(string, required): Field Type - Options: Checkbox, Currency, Date, Email, Number, Percent, Phone, Picklist, MultiselectPicklist, Text, TextArea, LongTextArea, Html, Time, UrldefaultCheckboxValue
(boolean, optional): Default value for checkbox fieldslength
(string, required): Length for numeric/text fieldsdecimalPlace
(string, required): Decimal places for numeric fieldspickListValues
(string, required): Values for picklist fields (separated by new lines)visibleLines
(string, required): Visible lines for multiselect/text area fieldsdescription
(string, optional): Field descriptionhelperText
(string, optional): Helper text shown on hoverdefaultFieldValue
(string, optional): Default field value
Description: Deploy custom fields for any object type.
Note: This is a flexible tool for creating custom fields on custom or unknown object types.
Advanced Operations
Description: Execute custom SOQL queries against your Salesforce data.
Parameters:
query
(string, required): SOQL Query (e.g., “SELECT Id, Name FROM Account WHERE Name = ‘Example’”)
Description: Deploy a new custom object in Salesforce.
Parameters:
label
(string, required): Object Label for tabs, page layouts, and reportspluralLabel
(string, required): Plural Label (e.g., “Accounts”)description
(string, optional): A description of the Custom ObjectrecordName
(string, required): Record Name that appears in layouts and searches (e.g., “Account Name”)
Description: Get the expected schema for operations on specific object types.
Parameters:
recordType
(string, required): Record Type to describeoperation
(string, required): Operation Type (e.g., “CREATE_RECORD” or “UPDATE_RECORD”)
Note: Use this function first when working with custom objects to understand their schema before performing operations.
Usage Examples
Basic Salesforce Agent Setup
from crewai import Agent, Task, Crew
from crewai_tools import CrewaiEnterpriseTools
# Get enterprise tools (Salesforce tools will be included)
enterprise_tools = CrewaiEnterpriseTools(
enterprise_token="your_enterprise_token"
)
# Create an agent with Salesforce capabilities
salesforce_agent = Agent(
role="CRM Manager",
goal="Manage customer relationships and sales processes efficiently",
backstory="An AI assistant specialized in CRM operations and sales automation.",
tools=[enterprise_tools]
)
# Task to create a new lead
create_lead_task = Task(
description="Create a new lead for John Doe from Example Corp with email john.doe@example.com",
agent=salesforce_agent,
expected_output="Lead created successfully with lead ID"
)
# Run the task
crew = Crew(
agents=[salesforce_agent],
tasks=[create_lead_task]
)
crew.kickoff()
Filtering Specific Salesforce Tools
from crewai_tools import CrewaiEnterpriseTools
# Get only specific Salesforce tools
enterprise_tools = CrewaiEnterpriseTools(
enterprise_token="your_enterprise_token",
actions_list=["salesforce_create_record_lead", "salesforce_update_record_opportunity", "salesforce_search_records_contact"]
)
sales_manager = Agent(
role="Sales Manager",
goal="Manage leads and opportunities in the sales pipeline",
backstory="An experienced sales manager who handles lead qualification and opportunity management.",
tools=enterprise_tools
)
# Task to manage sales pipeline
pipeline_task = Task(
description="Create a qualified lead and convert it to an opportunity with $50,000 value",
agent=sales_manager,
expected_output="Lead created and opportunity established successfully"
)
crew = Crew(
agents=[sales_manager],
tasks=[pipeline_task]
)
crew.kickoff()
Contact and Account Management
from crewai import Agent, Task, Crew
from crewai_tools import CrewaiEnterpriseTools
enterprise_tools = CrewaiEnterpriseTools(
enterprise_token="your_enterprise_token"
)
account_manager = Agent(
role="Account Manager",
goal="Manage customer accounts and maintain strong relationships",
backstory="An AI assistant that specializes in account management and customer relationship building.",
tools=[enterprise_tools]
)
# Task to manage customer accounts
account_task = Task(
description="""
1. Create a new account for TechCorp Inc.
2. Add John Doe as the primary contact for this account
3. Create a follow-up task for next week to check on their project status
""",
agent=account_manager,
expected_output="Account, contact, and follow-up task created successfully"
)
crew = Crew(
agents=[account_manager],
tasks=[account_task]
)
crew.kickoff()
Advanced SOQL Queries and Reporting
from crewai import Agent, Task, Crew
from crewai_tools import CrewaiEnterpriseTools
enterprise_tools = CrewaiEnterpriseTools(
enterprise_token="your_enterprise_token"
)
data_analyst = Agent(
role="Sales Data Analyst",
goal="Generate insights from Salesforce data using SOQL queries",
backstory="An analytical AI that excels at extracting meaningful insights from CRM data.",
tools=[enterprise_tools]
)
# Complex task involving SOQL queries and data analysis
analysis_task = Task(
description="""
1. Execute a SOQL query to find all opportunities closing this quarter
2. Search for contacts at companies with opportunities over $100K
3. Create a summary report of the sales pipeline status
4. Update high-value opportunities with next steps
""",
agent=data_analyst,
expected_output="Comprehensive sales pipeline analysis with actionable insights"
)
crew = Crew(
agents=[data_analyst],
tasks=[analysis_task]
)
crew.kickoff()
This comprehensive documentation covers all the Salesforce tools organized by functionality, making it easy for users to find the specific operations they need for their CRM automation tasks.
Getting Help
Need Help?
Contact our support team for assistance with Salesforce integration setup or troubleshooting.
Was this page helpful?
- Overview
- Prerequisites
- Available Tools
- Record Management
- Record Updates
- Record Retrieval
- Record Search
- List View Retrieval
- Custom Fields
- Advanced Operations
- Usage Examples
- Basic Salesforce Agent Setup
- Filtering Specific Salesforce Tools
- Contact and Account Management
- Advanced SOQL Queries and Reporting
- Getting Help