Salesforce CRM Integration
Last updated
Last updated
Salesforce CRM integration via Toollake allows businesses to automate lead generation, customer management, and account tracking seamlessly. This documentation provides step-by-step instructions on how to create leads, accounts, and customers, as well as retrieve information using the Salesforce module.
A valid Salesforce account.
Salesforce username, password, and security token.
Installed Groclake Toollake CRM Salesforce library.
Ensure you have Groclake installed in your environment:
pip install groclake
To interact with Salesforce, instantiate the Salesforce
class with the required credentials.
from groclake.toollake.crm.salesforce import Salesforce
sf = Salesforce(
username="[email protected]",
password="your_password",
security_token="your_security_token"
)
A Lead represents a potential customer. Use the create_lead
method to add a new lead.
lead_data = {
"FirstName": "John",
"LastName": "Doe",
"Email": "[email protected]",
"Company": "Tech Corp",
"Phone": "1234567890"
}
lead_id = sf.create_lead(lead_data)
print(f"Successfully created lead with ID: {lead_id}")
An Account represents a business entity.
account_id = sf.create_account(
company_name="New Tech Solutions",
industry="Technology"
)
print(f"Successfully created account with ID: {account_id}")
A Customer is represented as a Contact in Salesforce.
customer_data = {
"FirstName": "Jane",
"LastName": "Smith",
"Email": "[email protected]",
"Phone": "9876543210",
"Company": "Innovation Labs",
"Industry": "Research"
}
customer_id = sf.create_customer(customer_data)
print(f"Successfully created customer with ID: {customer_id}")
Retrieve a lead using an email identifier.
lead = sf.fetch_lead("[email protected]")
print(f"Found lead: {lead['FirstName']} {lead['LastName']}")
Retrieve an account by company name.
account = sf.fetch_account("Tech Corp")
print(f"Found account: {account['Name']}")
Retrieve a customer using an email identifier.
customer = sf.fetch_customer("[email protected]")
print(f"Found customer: {customer['FirstName']} {customer['LastName']}")
Retrieve all leads associated with a company.
company_leads = sf.fetch_account_leads("Tech Corp")
print(f"Found {len(company_leads)} leads for Tech Corp")
Retrieve all customers linked to an account.
account_customers = sf.fetch_account_customers(account['Id'])
print(f"Found {len(account_customers)} customers for {account['Name']}")
invalid_lead = {
"FirstName": "John",
"LastName": "Doe",
"Email": "invalid.email", # Invalid email format
"Company": "Tech Corp",
"Phone": "1234567890"
}
sf.create_lead(invalid_lead)
invalid_phone = {
"FirstName": "John",
"LastName": "Doe",
"Email": "[email protected]",
"Company": "Tech Corp",
"Phone": "123" # Too short
}
sf.create_lead(invalid_phone)
incomplete_data = {
"FirstName": "John",
"Email": "[email protected]", # Missing LastName
"Company": "Tech Corp",
"Phone": "1234567890"
}
sf.create_lead(incomplete_data)
The Salesforce CRM Integration using Toollake simplifies lead, customer, and account management with a structured API. By following the examples above, you can easily integrate Salesforce into your workflows, automate CRM tasks, and optimize business processes.