CRM/CSV
Overview
Section titled “Overview”Plasma provides powerful tools for managing customer relationship data through CSV files and direct CRM integrations.
Getting Started
Section titled “Getting Started”1. Prepare Your Data
Section titled “1. Prepare Your Data”Ensure your CSV files follow the correct format:
customers.csvcontacts.csvleads.csvcompanies.csvExample CSV structure:
id,name,email,phone,company,status,created_date1,John Doe,john@example.com,+1234567890,Acme Corp,active,2024-01-152,Jane Smith,jane@example.com,+0987654321,Tech Ltd,inactive,2024-01-162. Import Data
Section titled “2. Import Data”Use Plasma’s import functionality:
import { csvImporter } from 'plasma';
const result = await csvImporter.import('customers.csv', { mapping: { 'Customer Name': 'name', 'Email Address': 'email', 'Phone Number': 'phone', }, validation: true, batchSize: 1000,});3. Validate & Process
Section titled “3. Validate & Process”Review imported data and handle errors:
if (result.errors.length > 0) { console.log('Import errors:', result.errors);}
console.log(`Imported ${result.successful} records`);Data Formats
Section titled “Data Formats”Customer CSV Format
Section titled “Customer CSV Format”Required fields for customer data:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| id | string | number | ✅ | - | Unique customer identifier |
| name | string | ✅ | - | Customer full name |
| string | ✅ | - | Primary email address | |
| phone | string | ❌ | - | Phone number with country code |
| company | string | ❌ | - | Associated company name |
| status | ”active” | “inactive” | “prospect” | ❌ | “prospect” | Customer status |
Lead CSV Format
Section titled “Lead CSV Format”id,name,email,source,score,stage,assigned_to1,Alice Johnson,alice@test.com,website,85,qualified,john.doe2,Bob Wilson,bob@test.com,referral,65,contacted,jane.smithLead scoring integration:
const leadProcessor = await csvImporter.processLeads('leads.csv', { scoreThreshold: 70, autoAssign: true, notifyAssignee: true,});Company CSV Format
Section titled “Company CSV Format”id,name,domain,industry,size,revenue,location1,Acme Corp,acme.com,Technology,500,10000000,New York2,Tech Solutions,techsol.com,Consulting,50,2000000,CaliforniaContact CSV Format
Section titled “Contact CSV Format”id,first_name,last_name,email,title,company_id,department1,John,Doe,john@acme.com,Manager,1,Sales2,Jane,Smith,jane@acme.com,Developer,1,EngineeringCRM Integration
Section titled “CRM Integration”Salesforce Integration
Section titled “Salesforce Integration”Connect directly to Salesforce for real-time data sync:
import { crmIntegration } from 'plasma';
const salesforce = await crmIntegration.connect('salesforce', { clientId: process.env.SALESFORCE_CLIENT_ID, clientSecret: process.env.SALESFORCE_CLIENT_SECRET, sandbox: false,});
// Sync customersconst customers = await salesforce.getCustomers({ lastModified: new Date('2024-01-01'),});
// Export to CSVawait csvExporter.export(customers, 'salesforce-customers.csv');HubSpot Integration
Section titled “HubSpot Integration”Connect to HubSpot for contact and deal management:
const hubspot = await crmIntegration.connect('hubspot', { apiKey: process.env.HUBSPOT_API_KEY,});
// Bulk import contactsconst contacts = await csvImporter.parseFile('contacts.csv');await hubspot.bulkCreateContacts(contacts);Custom CRM Integration
Section titled “Custom CRM Integration”Build custom integrations for proprietary CRM systems:
class CustomCRMIntegration { async importData(csvFile: string) { const data = await csvImporter.parse(csvFile);
// Transform data to match CRM format const transformed = data.map((row) => ({ externalId: row.id, fullName: `${row.first_name} ${row.last_name}`, emailAddress: row.email, // Custom mapping logic }));
return this.bulkCreate(transformed); }}Data Validation
Section titled “Data Validation”Ensure data quality with built-in validation:
import { validator } from 'plasma';
const schema = { email: validator.email(), phone: validator.phone(), name: validator.string().min(2).max(100), company: validator.string().optional(), status: validator.enum(['active', 'inactive', 'prospect']),};
const validationResult = await csvImporter.validate('customers.csv', schema);
if (!validationResult.isValid) { console.log('Validation errors:', validationResult.errors);}Export Features
Section titled “Export Features”Export to multiple formats:
// Export filtered customer dataconst activeCustomers = await crm.getCustomers({ status: 'active', lastActivity: { since: '2024-01-01' },});
// Export to CSVawait csvExporter.export(activeCustomers, 'active-customers.csv');
// Export to Excelawait excelExporter.export(activeCustomers, 'active-customers.xlsx');
// Export to JSONawait jsonExporter.export(activeCustomers, 'active-customers.json');Batch Processing
Section titled “Batch Processing”Handle large datasets efficiently:
const batchProcessor = csvImporter.createBatchProcessor({ batchSize: 1000, concurrency: 5, retries: 3,});
batchProcessor.onProgress((progress) => { console.log(`Processed ${progress.completed}/${progress.total} records`);});
batchProcessor.onError((error, batch) => { console.error(`Batch ${batch.id} failed:`, error);});
await batchProcessor.process('large-dataset.csv');Best Practices
Section titled “Best Practices”Performance Tip: Use batch processing for files larger than 10,000 records to maintain optimal performance.
- Validate data before import
- Use consistent field naming
- Include unique identifiers
- Implement error handling
- Monitor import progress
- Backup data before bulk operations