@abhaythakur/prabhcrm-sdk
v1.1.0
Published
Official JavaScript SDK for PrabhCRM Platform API - Now with LinkedIn, Video Meetings & Calendar Integration
Maintainers
Readme
PrabhCRM JavaScript SDK
Official JavaScript SDK for integrating with PrabhCRM Platform API.
Installation
npm install @abhaythakur/prabhcrm-sdkQuick Start
import PrabhCRM from '@abhaythakur/prabhcrm-sdk';
const crm = new PrabhCRM({
apiKey: 'your_api_key',
orgId: 'your_org_id'
});
// Create a lead
const lead = await crm.leads.create({
full_name: 'Abhay Thakur',
email: '[email protected]',
phone: '+919876543210',
company: 'Acme Inc',
priority: 'HOT'
});
console.log('Lead created:', lead);Features
Leads Management
// Create lead
const lead = await crm.leads.create({
full_name: 'Abhay Thakur',
email: '[email protected]',
phone: '+919876543210',
company: 'Acme Inc',
custom_fields: {
budget: '50L',
timeline: 'Q1 2025'
}
});
// Get leads
const leads = await crm.leads.get({
status: 'new',
priority: 'HOT',
limit: 50
});
// Update lead
await crm.leads.update(leadId, {
status: 'contacted',
priority: 'WARM'
});
// Delete lead
await crm.leads.delete(leadId);AI Intelligence
// Get AI insights for a lead
const insights = await crm.ai.insights(leadId);
console.log('Likelihood to convert:', insights.likelihood_to_convert);
console.log('Recommended actions:', insights.recommended_actions);
console.log('Best contact time:', insights.best_contact_time);
// Trigger AI outreach
await crm.ai.outreach(leadId, {
channel: 'email',
context: 'Product demo request'
});
// Auto-enrich lead data
await crm.ai.enrich(leadId);
// Get organization insights
const orgInsights = await crm.ai.organizationInsights();
console.log('Conversion rate:', orgInsights.conversion_rate);Campaigns
// Create campaign
const campaign = await crm.campaigns.create({
name: 'Product Launch',
type: 'email',
target_leads: [1, 2, 3],
message_template: 'Hi {{name}}, check out our new product!'
});
// Get campaign stats
const stats = await crm.campaigns.getStats(campaignId);
console.log('Open rate:', stats.open_rate);
console.log('Click rate:', stats.click_rate);Workflows
// Create workflow
const workflow = await crm.workflows.create({
name: 'Hot Lead Follow-up',
trigger: 'lead_created',
conditions: {
priority: 'HOT'
},
actions: [
{
type: 'send_email',
template_id: 123
},
{
type: 'create_task',
assigned_to: 'sales_team'
}
]
});
// List workflows
const workflows = await crm.workflows.list();Webhooks
// Register webhook
const webhook = await crm.webhooks.register({
url: 'https://yourapp.com/webhook',
events: ['lead.created', 'lead.updated', 'deal.won'],
secret: 'your_webhook_secret'
});
// Verify webhook signature (in your webhook handler)
app.post('/webhook', (req, res) => {
const signature = req.headers['x-prabhcrm-signature'];
const isValid = crm.webhooks.verifySignature(
req.body,
signature,
'your_webhook_secret'
);
if (!isValid) {
return res.status(401).send('Invalid signature');
}
// Process webhook
console.log('Event:', req.body.event);
console.log('Data:', req.body.data);
res.status(200).send('OK');
});
// List webhooks
const webhooks = await crm.webhooks.list();
// Delete webhook
await crm.webhooks.delete(webhookId);Error Handling
try {
const lead = await crm.leads.create({
full_name: 'Abhay Thakur',
email: '[email protected]'
});
} catch (error) {
console.error('Error:', error.message);
}Configuration
const crm = new PrabhCRM({
apiKey: 'your_api_key', // Required
orgId: 'your_org_id', // Required
baseURL: 'https://api.prabhcrm.com/v1', // Optional
timeout: 30000 // Optional (default: 30s)
});Rate Limits
- Free Plan: 100 API calls/day
- Basic Plan: 1,000 API calls/day
- Pro Plan: 10,000 API calls/day
- Enterprise: Unlimited
Support
- Website: https://prabhcrm.com
- Documentation: https://prabhcrm.com/api-docs
- Email: [email protected]
- GitHub: https://github.com/prabhcrm/prabhcrm-sdk
License
MIT
New in v1.1.0 🎉
LinkedIn Integration
Connect your LinkedIn account and import connections as leads.
// Check LinkedIn connection status
const status = await crm.linkedin.getStatus();
console.log('Connected:', status.connected);
// Get OAuth URL to connect LinkedIn
const { authUrl } = await crm.linkedin.getAuthUrl();
// Redirect user to authUrl to authorize
// Get LinkedIn connections
const connections = await crm.linkedin.getConnections({
limit: 100,
offset: 0
});
console.log('Connections:', connections.connections);
// Import selected connections as leads
await crm.linkedin.importConnections([
{
name: 'John Doe',
email: '[email protected]',
profileUrl: 'https://linkedin.com/in/johndoe',
headline: 'CEO at Company',
company: 'Company Inc'
}
]);
// Sync all connections
await crm.linkedin.syncConnections();
// Disconnect LinkedIn
await crm.linkedin.disconnect();Video Meetings
Create and manage video meetings with built-in video conferencing.
// Create a meeting
const meeting = await crm.meetings.create({
title: 'Product Demo',
description: 'Demo of our new features',
start_time: '2024-12-10T10:00:00Z',
duration: 60, // minutes
participants: ['[email protected]', '[email protected]']
});
console.log('Meeting ID:', meeting.id);
console.log('Room ID:', meeting.room_id);
// Get meeting join URL
const { url, roomId } = await crm.meetings.getJoinUrl(meeting.id);
console.log('Join URL:', url);
// Share this URL with participants
// List meetings
const meetings = await crm.meetings.list({
status: 'upcoming',
from: '2024-12-01T00:00:00Z',
to: '2024-12-31T23:59:59Z'
});
// Get meeting details
const meetingDetails = await crm.meetings.get(meeting.id);
// Update meeting
await crm.meetings.update(meeting.id, {
title: 'Updated Product Demo',
start_time: '2024-12-10T11:00:00Z'
});
// Get participants
const participants = await crm.meetings.getParticipants(meeting.id);
// Add participant
await crm.meetings.addParticipant(meeting.id, '[email protected]');
// Cancel meeting
await crm.meetings.cancel(meeting.id);Calendar Integration
Manage calendar events and sync with external calendars.
// Create calendar event
const event = await crm.calendar.createEvent({
title: 'Follow-up Call',
description: 'Call with lead about pricing',
start_time: '2024-12-10T14:00:00Z',
end_time: '2024-12-10T14:30:00Z',
type: 'meeting' // meeting, task, or reminder
});
// Get calendar events
const events = await crm.calendar.getEvents({
from: '2024-12-01T00:00:00Z',
to: '2024-12-31T23:59:59Z',
type: 'meeting'
});
// Update event
await crm.calendar.updateEvent(event.id, {
title: 'Updated Follow-up Call',
start_time: '2024-12-10T15:00:00Z'
});
// Delete event
await crm.calendar.deleteEvent(event.id);
// Sync with external calendar (Google, Outlook)
await crm.calendar.syncExternal('google', 'google_auth_token');Complete Example
Here's a complete example showing how to use multiple features together:
import PrabhCRM from '@abhaythakur/prabhcrm-sdk';
const crm = new PrabhCRM({
apiKey: process.env.PRABHCRM_API_KEY,
orgId: process.env.PRABHCRM_ORG_ID
});
async function main() {
try {
// 1. Import LinkedIn connections as leads
const linkedinStatus = await crm.linkedin.getStatus();
if (linkedinStatus.connected) {
const connections = await crm.linkedin.getConnections({ limit: 50 });
// Import high-value connections
const highValueConnections = connections.connections.filter(c =>
c.headline.includes('CEO') || c.headline.includes('Founder')
);
await crm.linkedin.importConnections(highValueConnections);
console.log(`Imported ${highValueConnections.length} high-value leads`);
}
// 2. Get AI insights for new leads
const leads = await crm.leads.get({ status: 'new', limit: 10 });
for (const lead of leads.data) {
const insights = await crm.ai.insights(lead.id);
if (insights.likelihood_to_convert > 0.7) {
// 3. Schedule a meeting for high-potential leads
const meeting = await crm.meetings.create({
title: `Demo for ${lead.full_name}`,
description: 'Product demonstration',
start_time: new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString(),
duration: 30,
participants: [lead.email]
});
// 4. Create calendar event
await crm.calendar.createEvent({
title: `Prep for ${lead.full_name} demo`,
start_time: new Date(Date.now() + 23 * 60 * 60 * 1000).toISOString(),
end_time: new Date(Date.now() + 23.5 * 60 * 60 * 1000).toISOString(),
type: 'task'
});
console.log(`Scheduled meeting for ${lead.full_name}`);
}
}
// 5. Set up webhook for real-time updates
await crm.webhooks.register({
url: 'https://yourapp.com/webhook',
events: ['lead.created', 'meeting.scheduled', 'deal.won'],
secret: process.env.WEBHOOK_SECRET
});
console.log('✅ Automation setup complete!');
} catch (error) {
console.error('Error:', error.message);
}
}
main();TypeScript Support
The SDK includes TypeScript definitions for better IDE support:
import PrabhCRM from '@abhaythakur/prabhcrm-sdk';
interface LeadData {
full_name: string;
email: string;
phone?: string;
company?: string;
priority?: 'HOT' | 'WARM' | 'COLD';
}
const crm = new PrabhCRM({
apiKey: process.env.PRABHCRM_API_KEY!,
orgId: process.env.PRABHCRM_ORG_ID!
});
const lead: LeadData = {
full_name: 'John Doe',
email: '[email protected]',
priority: 'HOT'
};
await crm.leads.create(lead);Migration from v1.0.0
If you're upgrading from v1.0.0, no breaking changes! All existing code will continue to work. Simply install the latest version:
npm install @abhaythakur/prabhcrm-sdk@latestNew features are additive and backward compatible.
Changelog
v1.1.0 (December 2024)
- ✅ Added LinkedIn integration API
- ✅ Added video meetings API
- ✅ Added calendar integration API
- ✅ Enhanced error handling
- ✅ Improved TypeScript support
- ✅ Added comprehensive examples
v1.0.0 (November 2024)
- Initial release
- Leads management
- AI intelligence
- Campaigns
- Workflows
- Webhooks
