Skip to main content

Create InstaSite Automation Processor

Overview​

The Create InstaSite automation generates instant websites (InstaSites) for business contacts associated with deals when they enter a specific pipeline stage. Supports custom templates and email/SMS notifications to share the site.

Source File: queue-manager/queues/deals/automations/instasite.js
Triggered By: queue-manager/services/deals/automations.js
Business Impact: HIGH - Lead engagement & value delivery

Processing Logic​

sequenceDiagram
participant AUTO as Automation Service
participant QUEUE as InstaSite Queue
participant DEAL as Deals
participant CONTACT as Contacts
participant SITE as InstaSite Utility
participant NOTIFY as Email/SMS

AUTO->>QUEUE: Add automation job
QUEUE->>DEAL: Find eligible deals<br/>(with business contact)

loop For Each Deal
QUEUE->>CONTACT: Validate business contact
QUEUE->>SITE: Create instasite<br/>(template + business)
SITE-->>QUEUE: Site ID & URL

opt Notifications Enabled
QUEUE->>NOTIFY: Send email/SMS with site link
end

QUEUE->>DEAL: Mark automation triggered
end

Key Features​

Template Requirement​

const templateID =
automation.data && automation.data.template_id ? automation.data.template_id : null;

if (!templateID) {
throw new Error('Template not provided!');
}

Business Contact Requirement​

// Only processes deals with business contacts
const business = deal.business ? deal.business : null;

if (business) {
// Create instasite
} else {
throw new Error('No business contact associated with deal');
}

Notification Configuration​

const notifications =
automation.data && automation.data.notifications ? automation.data.notifications : {};

// Normalize field names
if (notifications.sms?.message) notifications.sms.content = notifications.sms.message;
if (notifications.email?.message) notifications.email.content = notifications.email.message;

InstaSite Creation​

const result = await addInstasite(
accountID,
userID,
[business], // Array of business contacts
notifications,
templateID
);

// Result format
{
deal: dealID,
instasite: result[0], // Site details
business: businessID
}

Collections Used​

Input: deal-automation
Query: deal (with business field)
Validation: contact (business contact)
Create: instasites-* collections (via utility)
Optional: communication (email/SMS records)

Automation Data Structure​

{
template_id: ObjectId("templateId"), // Required
notifications: {
email: {
enabled: true,
subject: "Your Custom Website is Ready!",
content: "Hi {{business.company}}, we've created a website for you...",
sender: "websites@company.com"
},
sms: {
enabled: true,
content: "Your website is live: {{site.url}}"
}
}
}

Use Cases​

Example 1: Instant Lead Engagement​

// Automation
{
stage_id: "new_lead",
action: "create_instasite",
data: {
template_id: businessProfileTemplateID,
notifications: {
email: {
enabled: true,
subject: "We Created a Website for {{business.company}}!",
content: "As a demonstration of our web design capabilities, we've built a custom website for your business..."
}
}
},
delay: 0
}

// Result: Instant credibility and value demonstration

Example 2: Proposal Visualization​

// Automation
{
stage_id: "proposal_sent",
action: "create_instasite",
data: {
template_id: mockupTemplateID,
notifications: {
email: {
enabled: true,
subject: "Preview Your New Website - {{business.company}}",
content: "To help you visualize our proposal, here's a mockup of your new website..."
},
sms: {
enabled: true,
content: "Preview your new site design: {{site.url}}"
}
}
},
delay: 3600 // 1 hour after proposal
}

Example 3: Onboarding Deliverable​

// Automation
{
stage_id: "closed_won",
action: "create_instasite",
data: {
template_id: starterSiteTemplateID,
notifications: {
email: {
enabled: true,
subject: "Your Website is Live!",
content: "Welcome! Your starter website is now live and ready to customize..."
}
}
},
delay: 0
}

InstaSite vs InstaReport​

FeatureInstaSiteInstaReport
OutputLive websitePDF/HTML report
PurposeEngagement, demo, deliverableData analysis, insights
EditingCustomer can edit contentStatic, read-only
HostingDashClicks subdomainHosted report URL
TemplatesWebsite designsReport layouts

Error Handling​

Common Errors​

  1. No Template: template_id not provided
  2. Invalid Business: Contact doesn't exist
  3. No Business: Deal has no business contact
  4. Template Not Found: Invalid template ID
  5. Site Generation Failed: Utility error

Error Response​

{
deal: dealID,
instasite: null,
business: businessID,
message: "No business contact associated with deal",
additional_info: {...}
}

Notification Flow​

  1. InstaSite Created: Website generated with template
  2. Email Sent (if enabled): Email with site link and credentials
  3. SMS Sent (if enabled): SMS with shortened site link
  4. Activity Logged: Site creation tracked

Merge Fields in Notifications​

Available merge fields:

  • {{business.company}} - Business name
  • {{business.phone}} - Phone number
  • {{business.email}} - Email address
  • {{site.url}} - InstaSite URL
  • {{site.edit_url}} - Edit/admin URL
  • {{user.name}} - Creating user name
  • {{deal.name}} - Deal name

Performance​

Execution Time: 3-8 seconds per site (site generation intensive)
Batch Processing: Sequential (not parallel) due to generation load
Complexity: HIGH
Lines of Code: 179


Business Value: Lead engagement, value demonstration, fast time-to-delivery

💬

Documentation Assistant

Ask me anything about the docs

Hi! I'm your documentation assistant. Ask me anything about the docs!

I can help you with:
- Code examples
- Configuration details
- Troubleshooting
- Best practices

Try asking: How do I configure the API?
09:31 AM