Salesforce Integration
Overview
Section titled “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
Section titled “Prerequisites”Before using the Salesforce integration, ensure you have:
- A CrewAI AMP account with an active subscription
- A Salesforce account with appropriate permissions
- Connected your Salesforce account through the Integrations page
Setting Up Salesforce Integration
Section titled “Setting Up Salesforce Integration”1. Connect Your Salesforce Account
Section titled “1. Connect Your Salesforce Account”- Navigate to CrewAI AMP Integrations.
- Find Salesforce in the Authentication Integrations section.
- Click Connect.
What happens next depends on whether a Salesforce admin in your org has already installed the CrewAI package:
- Package already installed: you’re taken straight to the Salesforce OAuth consent screen — approve it and you’re connected.
- Package not installed yet: you’ll see an Install CrewAI in Salesforce page. Follow the one-time install steps below, then come back to CrewAI AMP and click Connect again.
- Grant the necessary permissions for CRM and sales management.
- Copy your Enterprise Token from Integration Settings.
One-time admin install (Salesforce admin only)
Section titled “One-time admin install (Salesforce admin only)”The first time anyone in your org clicks Connect Salesforce, CrewAI redirects them to an install page that points at the CrewAI managed package. A Salesforce admin needs to install it once for the whole org.
- On the install page in CrewAI, click Install in Salesforce. (You can also share the page URL with your admin — the install link works for anyone who opens it.)
- Sign in to Salesforce as an admin. For sandboxes, swap
login.salesforce.comfortest.salesforce.comin the URL before opening it. - Choose Install for All Users, acknowledge the third-party app prompt, and click Install.
- In Salesforce Setup, search External Client App Manager → CrewAI
App → open the Policies tab → Edit and set:
- Permitted Users: All users may self-authorize
- IP Relaxation: Relax IP restrictions
- Refresh Token Policy: Refresh token is valid until revoked
- Save.
- Return to CrewAI AMP and click Connect Salesforce again. OAuth will complete this time.
2. Install Required Package
Section titled “2. Install Required Package”uv add crewai-tools3. Environment Variable Setup
Section titled “3. Environment Variable Setup”export CREWAI_PLATFORM_INTEGRATION_TOKEN="your_enterprise_token"Or add it to your .env file:
CREWAI_PLATFORM_INTEGRATION_TOKEN=your_enterprise_tokenAvailable Tools
Section titled “Available Tools”Record Management
Section titled “Record Management”salesforce/create_record_contact
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
salesforce/create_record_lead
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
salesforce/create_record_opportunity
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
salesforce/create_record_task
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
salesforce/create_record_account
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
salesforce/create_record_any
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
Section titled “Record Updates”salesforce/update_record_contact
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
salesforce/update_record_lead
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
salesforce/update_record_opportunity
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
salesforce/update_record_task
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
salesforce/update_record_account
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
salesforce/update_record_any
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
Section titled “Record Retrieval”salesforce/get_record_by_id_contact
Description: Get a Contact record by its ID.
Parameters:
recordId(string, required): Record ID of the Contact
salesforce/get_record_by_id_lead
Description: Get a Lead record by its ID.
Parameters:
recordId(string, required): Record ID of the Lead
salesforce/get_record_by_id_opportunity
Description: Get an Opportunity record by its ID.
Parameters:
recordId(string, required): Record ID of the Opportunity
salesforce/get_record_by_id_task
Description: Get a Task record by its ID.
Parameters:
recordId(string, required): Record ID of the Task
salesforce/get_record_by_id_account
Description: Get an Account record by its ID.
Parameters:
recordId(string, required): Record ID of the Account
salesforce/get_record_by_id_any
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
Section titled “Record Search”salesforce/search_records_contact
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
salesforce/search_records_lead
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
salesforce/search_records_opportunity
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
salesforce/search_records_task
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
salesforce/search_records_account
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
salesforce/search_records_any
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
Section titled “List View Retrieval”salesforce/get_record_by_view_id_contact
Description: Get Contact records from a specific List View.
Parameters:
listViewId(string, required): List View IDpaginationParameters(object, optional): Pagination settings with pageCursor
salesforce/get_record_by_view_id_lead
Description: Get Lead records from a specific List View.
Parameters:
listViewId(string, required): List View IDpaginationParameters(object, optional): Pagination settings with pageCursor
salesforce/get_record_by_view_id_opportunity
Description: Get Opportunity records from a specific List View.
Parameters:
listViewId(string, required): List View IDpaginationParameters(object, optional): Pagination settings with pageCursor
salesforce/get_record_by_view_id_task
Description: Get Task records from a specific List View.
Parameters:
listViewId(string, required): List View IDpaginationParameters(object, optional): Pagination settings with pageCursor
salesforce/get_record_by_view_id_account
Description: Get Account records from a specific List View.
Parameters:
listViewId(string, required): List View IDpaginationParameters(object, optional): Pagination settings with pageCursor
salesforce/get_record_by_view_id_any
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
Section titled “Custom Fields”salesforce/create_custom_field_contact
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
salesforce/create_custom_field_lead
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
salesforce/create_custom_field_opportunity
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
salesforce/create_custom_field_task
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
salesforce/create_custom_field_account
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
salesforce/create_custom_field_any
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
Section titled “Advanced Operations”salesforce/write_soql_query
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’”)
salesforce/create_custom_object
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”)
salesforce/describe_action_schema
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
Section titled “Usage Examples”Basic Salesforce Agent Setup
Section titled “Basic Salesforce Agent Setup”from crewai import Agent, Task, Crewfrom crewai import Agent, Task, Crew
# Create an agent with Salesforce capabilitiessalesforce_agent = Agent( role="CRM Manager", goal="Manage customer relationships and sales processes efficiently", backstory="An AI assistant specialized in CRM operations and sales automation.", apps=['salesforce'] # All Salesforce actions will be available)
# Task to create a new leadcreate_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 taskcrew = Crew( agents=[salesforce_agent], tasks=[create_lead_task])
crew.kickoff()Filtering Specific Salesforce Tools
Section titled “Filtering Specific Salesforce Tools”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.", apps=['salesforce/create_record_lead'])
# Task to manage sales pipelinepipeline_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
Section titled “Contact and Account Management”from crewai import Agent, Task, Crew
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.", apps=['salesforce'])
# Task to manage customer accountsaccount_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
Section titled “Advanced SOQL Queries and Reporting”from crewai import Agent, Task, Crew
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.", apps=['salesforce'])
# Complex task involving SOQL queries and data analysisanalysis_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
Section titled “Getting Help”Need Help?
Contact our support team for assistance with Salesforce integration setup or troubleshooting.