DEV Community

Cover image for Automating Student Onboarding via WhatsApp in SugarCRM
Northbeam Technologies
Northbeam Technologies

Posted on • Originally published at northbeam-tech.com

Automating Student Onboarding via WhatsApp in SugarCRM

A multi-step conversation engine that captures leads and creates CRM records automatically — no staff required.

The Problem

When prospective students first contact the school via WhatsApp, staff had to manually collect their details and create a record in SugarCRM by hand. Leads that arrived outside business hours were simply missed or delayed — there was no way to capture them without a person in the loop.

The school was already using Twilio for outbound WhatsApp messages from SugarCRM, but replies from unknown numbers went nowhere.

What We Built

A multi-step conversation engine built directly into SugarCRM. When an unknown number sends a WhatsApp message, the system:

  1. Intercepts the message via a Twilio webhook
  2. Checks whether the phone number already exists as a student record
  3. If yes → routes to the existing follow-up flow (no change)
  4. If no → starts a guided intake questionnaire, validates each answer, and creates the student record automatically

Zero admin involvement for new contacts.

How It Works

Key Technical Decisions

State machine, not a script.

Each conversation is a session with a current_step pointer. Questions can be reordered, toggled, or mapped to any CRM field without changing code. Admins manage the question bank directly from SugarCRM's UI.

Phone number normalization.

The system normalizes Israeli, US, and Vietnamese number formats before matching — preventing duplicate records from format variations like +1-555... vs 001555....

Media guard.

If a student sends a photo or voice note, the system replies politely that only text is supported and automatically resends the current question.

Partial completion handling.

If a student stops mid-flow, automated reminders go out at 2h and 24h. If minimum data (name + phone) is collected and the student still doesn't respond, a partial record is saved so the lead isn't lost.

Multi-number support.

Multiple Twilio sender numbers can be registered in SugarCRM. Each conversation session locks to the number the student originally contacted.

What Changed After Launch

  • ✅ Student record creation from WhatsApp is fully automated for new contacts
  • ✅ Leads outside business hours are captured without any staff intervention
  • ✅ Admins can view full chat history, manually resume sessions, or override any step from inside SugarCRM
  • ✅ The existing outbound messaging workflow for known students is completely unchanged

Stack

  • PHP — core logic and SugarCRM custom modules
  • SugarCRM — custom modules for session management, question bank, and student records
  • Twilio WhatsApp API — inbound webhook + outbound messaging
  • MySQL — session state persistence

The main lesson here: WhatsApp bots don't need a separate platform. If your CRM already has a webhook endpoint and an API, you can build the conversation engine right inside it — and keep everything in one place for your team.


Originally published on northbeam-tech.com

Top comments (1)

Collapse
 
johnmaxwell002 profile image
John Maxwell

Impressive implementation! I really like the state-machine approach it makes the onboarding flow much easier to maintain and scale. I've built similar CRM automations with Twilio/WhatsApp, custom webhooks, and conversation workflows, so if you ever want to add AI responses, appointment booking, payment collection, or more advanced automation inside SugarCRM, I'd be happy to collaborate.