Skip to content

feat: Emergent automation pipeline for website generation#1

Open
alokit-bot wants to merge 17 commits into
masterfrom
feature/places-assets
Open

feat: Emergent automation pipeline for website generation#1
alokit-bot wants to merge 17 commits into
masterfrom
feature/places-assets

Conversation

@alokit-bot

Copy link
Copy Markdown
Owner

Summary

This PR adds the full Emergent.sh automation pipeline for the Nextahalli website-building workflow.

What is this?

Given a business from our leads list, this automation:

  1. Creates a task on Emergent.sh via API (no browser needed)
  2. Monitors the build — polls for completion, auto-responds to HITL questions
  3. Previews at 4 viewports (phone, tablet, laptop, TV)
  4. Quality-assesses the output
  5. Saves to GitHub via the Emergent UI flow
  6. Deploys to GitHub Pages with a clean static build
  7. Reports credit usage (starting ECU → ending ECU → credits consumed)

Files Added

File Purpose
scripts/emergent-client.mjs REST API client for Emergent.sh (auth, task creation, HITL, credits, GitHub)
scripts/emergent-build.mjs Full build orchestrator with polling, auto-HITL, quality check
scripts/deploy-gh-pages.sh Clone → build → fix → push to gh-pages (handles CRA quirks)
scripts/pipeline.mjs End-to-end orchestrator (fetch assets → build → deploy)
scripts/prompt-template.md Parameterized prompt template for any business
scripts/respond-to-agent.mjs Standalone HITL response tool

Tested E2E

Envoq Salon - Jayanagar (lead #9, 4.9★, 1200 reviews)

Style n Arts - HSR Layout (lead #4, 4.9★, 1700 reviews) — in progress

Key Bugs Fixed

  1. HITL API: client_ref_id + id must match original job (not a new UUID)
  2. Blank gh-pages: Emergent injects emergent-main.js which breaks the frontend without a backend — stripped during deploy
  3. React Router: BrowserRouter needs basename for gh-pages sub-paths
  4. CRA/Node compat: ajv@8 needed for newer Node versions

Credit Reporting

Every build now reports:

💰 Starting balance: 17.80 ECU (7.80 monthly + 10.00 daily)
💰 Ending balance: 15.57 ECU (5.57 monthly + 10.00 daily)
💸 Credits used: 2.23 ECU

@avikalpg — ready for your review!

…eploy-gh-pages, pipeline)

- emergent-client.mjs: Full API client with auth, token refresh, all endpoints
- emergent-build.mjs: Build orchestrator with HITL detection and auto-response
- deploy-gh-pages.sh: Clone → build → fix → deploy to GitHub Pages
- pipeline.mjs: End-to-end orchestrator
- prompt-template.md: Parameterized template for any business type

Key fixes:
- HITL response requires matching client_ref_id + id to original job
- BrowserRouter needs basename for gh-pages sub-paths
- Remove emergent-main.js from build (causes blank page without backend)
- Add 'do not ask questions' instruction to prompt template

Tested E2E with Envoq Salon - Jayanagar:
- Emergent build: https://beauty-jaya-salon.preview.emergentagent.com/
- GitHub repo: https://github.com/alokit-bot/envoq-salon-website
- GitHub Pages: https://alokit-bot.github.io/envoq-salon-website/
- getCreditsBalance() and getCreditsSummary() in emergent-client.mjs
- emergent-build.mjs now reports starting/ending balance and credits used
- Balance info saved in build-log.json under 'credits' field
- deploy-gh-pages.sh: GH_PAT now required from env/.env (no hardcoded default)
- emergent-client.mjs: email, password, supabase key from env/.env via dotenv
- .gitignore: added .env, .env.*, .emergent-token-cache.json
- Installed dotenv dependency
- Deploy script now accepts optional details.json path (3rd arg)
- Auto-extracts business name from built HTML if no details.json
- Adds og:title, og:description, og:url, og:type tags
- Adds twitter:card meta tags
- Strips emergent-main.js, emergent-badge, and Emergent meta description
- Fixes CRACO/Node 22 build (auto-installs ajv@8)
- Pipeline passes details.json to deploy script automatically
Searches DuckDuckGo for business name + location, scores results
against aggregator domains, and flags potential existing websites.
Non-blocking — prints warning and continues.

Tested: catches anandabhavan.com (score 7), no false positives on
Style n Arts or Envoq Salon.
- extract-branding.mjs: 2-phase script
  Phase 1: finds photos in asset dir, outputs vision prompt
  Phase 2: takes vision model response, generates branding.json with:
    - Logo description (text, font, colors, layout, icons)
    - Brand color palette (hex codes)
    - Brand vibe
    - Ready-to-use promptSnippet for Emergent

- prompt-template.md: updated to inject BRANDING_SNIPPET when available,
  falls back to manual COLOR_PALETTE/FONT_STYLE fields

Pipeline flow:
1. Agent captures storefront/entrance photos from Google Maps
2. extract-branding.mjs Phase 1 outputs vision request
3. Agent runs vision model on photos
4. extract-branding.mjs Phase 2 generates branding.json
5. Pipeline injects branding.promptSnippet into Emergent prompt
6. Emergent agent builds website matching real business branding
- PLAYBOOK.md: positioning, customer segments, 4 message variants (A-D),
  experiment design, follow-up cadence, qualifying questions, handoff rules
- tracker.json: outreach tracking schema with conversion funnel
- segment-rules.json: auto-segmentation rules + round-robin variant assignment

Designed for A/B testing opening messages across 6 customer segments:
restaurant-popular, restaurant-premium, salon-boutique, fitness-gym,
healthcare, bar-lounge. Each segment has a default variant order.
Statistical approach: min 5 per variant/segment, favor winner at 10+,
lock at 20+.
…hics

Replaced rigid 6-segment model (restaurant-popular, salon-boutique, etc.)
with psychographic signal-based approach per Guillebeau's 'New Demographies'.

Signals observed per business: digital_awareness, brand_pride,
review_responsive, growth_phase, name_language, review_themes, etc.

Key change: segments EMERGE from data after 20+ sends, not defined upfront.
First 20 sends are pure exploration. Analysis looks for signal clusters
that correlate with reply rates.
SOMRAS (Variant B) → 919663846153
Envoq Salon (Variant A) → 919955885574
Style n Arts (Variant D) → 917760711425

All sent 2026-04-05 14:30 UTC via WhatsApp business account
Indian Biere House (Variant B) → 919036125832
Live Fitness HSR (Variant C) → 919066172892
Coal Spark skipped — has existing website (smart.coalspark.com)
Total: 5 businesses reached
Introduces Avi's IIT Kanpur / ex-Microsoft credentials as trust signal.
4 variants for A/B testing. Framed as vision, not flex.
Sent from Alokit's number — Avi is positioned as founder behind initiative.
- enrich-business.sh: scrapes Zomato/JustDial + merges with details.json
- enrich-from-gmaps.mjs: DDG-based enrichment (reviews, menu, pricing)
- generate-rich-prompt.mjs: combines all data sources into rich Emergent prompt
- scrape-gmaps.mjs: browser-based GMaps scraping (for agent use)

Cron updated: Step 3 (Enrich) now mandatory before building.
Timeout increased to 2h to allow for quality enrichment + builds.
Single command: node scripts/pipeline.mjs --name X --area Y --slug Z --phone P

Steps:
1. ENRICH: web presence check → Zomato/JustDial scrape → merge details.json → generate rich prompt
2. BUILD: submit enriched prompt to Emergent → poll → get preview URL
3. DEPLOY: outputs exact commands for GitHub save + gh-pages deploy
4. OUTREACH: outputs WhatsApp message with variant selection

Batch mode: --batch --count N reads lead_shortlist.md, skips already-contacted
- scrape-gmaps-cli.sh: uses openclaw browser CLI to extract real address,
  phone, hours, category, highlights from Google Maps
- Pipeline step 1a.0: seeds details.json with known args (rating, reviews)
- Pipeline step 1a.5: runs Google Maps scrape before Zomato enrichment
- Result: prompts now have real addresses + real hours from Maps,
  plus ratings/reviews from our CSV, merged into one details.json

Data flow: args (rating/reviews) → seed details.json → GMaps scrape
(address/hours/phone) → enrich-business.sh (Zomato reviews) → merge
→ generate-rich-prompt.mjs → Emergent build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants