Salesforce CRM Integration
Introduction
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.
Prerequisites
A valid Salesforce account.
Salesforce username, password, and security token.
Installed Groclake Toollake CRM Salesforce library.
Installation
Ensure you have Groclake installed in your environment:
pip install groclake
Initializing Salesforce Connection
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"
)
Creating a Lead
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}")
Creating an Account
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}")
Creating a Customer (Contact)
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}")
Fetching a Lead
Retrieve a lead using an email identifier.
lead = sf.fetch_lead("[email protected]")
print(f"Found lead: {lead['FirstName']} {lead['LastName']}")
Fetching an Account
Retrieve an account by company name.
account = sf.fetch_account("Tech Corp")
print(f"Found account: {account['Name']}")
Fetching a Customer
Retrieve a customer using an email identifier.
customer = sf.fetch_customer("[email protected]")
print(f"Found customer: {customer['FirstName']} {customer['LastName']}")
Fetching All Leads for a Company
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")
Fetching All Customers for an Account
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']}")
Validation Cases & Error Handling
Invalid Email Format
invalid_lead = {
"FirstName": "John",
"LastName": "Doe",
"Email": "invalid.email", # Invalid email format
"Company": "Tech Corp",
"Phone": "1234567890"
}
sf.create_lead(invalid_lead)
Invalid Phone Number
invalid_phone = {
"FirstName": "John",
"LastName": "Doe",
"Email": "[email protected]",
"Company": "Tech Corp",
"Phone": "123" # Too short
}
sf.create_lead(invalid_phone)
Missing Required Fields
incomplete_data = {
"FirstName": "John",
"Email": "[email protected]", # Missing LastName
"Company": "Tech Corp",
"Phone": "1234567890"
}
sf.create_lead(incomplete_data)
Conclusion
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.
Last updated