โ† Back to Case Studies
Automation Project ยท IIT Patna

WhatsApp-Triggered Class Cancellation Automation

Node.js Python Microsoft SMTP WhatsApp Automation Academic Operations
๐Ÿ’ฌ
WhatsApp message sent
โ†’
๐Ÿค–
Node.js bot detects
โ†’
๐Ÿ
Python script runs
โ†’
๐Ÿ“‹
Excel lookup
โ†’
โœ‰๏ธ
Email auto-sent

The Problem

At IIT Patna, class cancellations were handled entirely through manual communication. A faculty member would inform the academic office, who would then manually compose and send an email to each affected student group โ€” a process that took 10โ€“15 minutes per cancellation and required someone to be available at a computer at all times.

With 60+ active courses across programmes and 10,000+ enrolled students, even a single missed or delayed cancellation notice caused student confusion, unnecessary travel, and support tickets to the academic office.

The manual process also had no audit trail โ€” there was no reliable record of which classes had been cancelled, when the notice was sent, or who was notified.

The Solution

I designed and built a complete end-to-end automation system that reduces the entire cancellation workflow to a single WhatsApp message. The system is triggered by me โ€” not faculty directly โ€” which ensures message quality and prevents accidental triggers from unrelated WhatsApp activity.

The message format is simple and consistent: Course Code | Date | Cancelled. Within seconds of sending, the system automatically looks up the course in the master database, identifies all associated email aliases, composes a formatted cancellation notice, and sends it โ€” all without any manual intervention.

How It Was Built

1
WhatsApp Bot โ€” Node.js
Built using whatsapp-web.js, the bot monitors WhatsApp for messages sent by me only (msg.fromMe filter). Messages from all other contacts and groups are completely ignored. When a message containing the pipe | delimiter is detected, the bot extracts the text and passes it to the Python script as a command-line argument.
2
Course Database โ€” Excel Lookup
A structured courses.xlsx file maps every course code to its name and email aliases. Multiple aliases per course are supported (e.g. CDA 101 notifies both CSDA and AICS student groups simultaneously). The Python script uses pandas to query this file and extract all relevant details in milliseconds.
3
Email Automation โ€” Microsoft SMTP
Emails are sent via Microsoft Office 365 SMTP using the institutional moodle_support@iitp.ac.in account. The system automatically constructs a formatted cancellation notice, addresses it to all course aliases, and CCs cet_off@iitp.ac.in for administrative records โ€” all in a single automated send.
4
Cancellation Log โ€” Excel Audit Trail
Every cancellation is automatically appended to cancellation_log.xlsx with a timestamp, course code, course name, date, and status. This creates a permanent audit trail for academic administration โ€” something the manual process completely lacked.

The Code

The WhatsApp bot listens for messages sent by the operator and triggers the Python script:

bot.js โ€” Node.js
// Only trigger on operator's own messages client.on('message_create', msg => { if (msg.fromMe && msg.body.includes("|")) { exec(`python "cancel_class.py" "${msg.body}"`, (error, stdout) => console.log(stdout)); } });

The Python script parses the message, queries the course database, and sends the email:

cancel_class.py โ€” Python
# Parse WhatsApp message course, date, status = [x.strip() for x in message.split("|")] # Lookup course in Excel database df = pd.read_excel("courses.xlsx") row = df[df["Course Code"] == course] # Handle multiple email aliases per course alias_list = [x.strip() for x in row["Alias"].values[0].split(",")] recipients = alias_list + [""] # Send via Microsoft SMTP server = smtplib.SMTP("smtp.office365.com", 587) server.starttls() server.login("", PASSWORD) server.sendmail(SENDER, recipients, msg.as_string())

The msg.fromMe filter is the key security design โ€” the bot ignores 100% of incoming WhatsApp messages from faculty, students, groups, and all other contacts. Only messages sent by the operator trigger the automation.

Handling Multiple Aliases

Several courses at IIT Patna serve multiple student cohorts simultaneously. For example, CDA 101 (Mathematics-I) is taken by both CSDA and AICS students โ€” requiring notification to two separate email groups from a single cancellation command.

The system handles this automatically by parsing comma-separated aliases from the Excel database and sending to all of them in a single email operation:

courses.xlsx โ€” Multiple aliases
CDA 101 | Mathematics-I |

A single WhatsApp message notifies both student groups, the CC recipient, and creates one unified log entry โ€” with zero additional effort.

Before vs After

Before โ€” Manual
Faculty informs office โ†’ Admin opens Outlook โ†’ Manually finds alias โ†’ Writes email โ†’ Sends โ†’ No log created

Time: 10โ€“15 minutes
After โ€” Automated
Send one WhatsApp message โ†’ Email auto-sent to all aliases โ†’ CC sent โ†’ Log entry created automatically

Time: under 10 seconds

Tech Stack

Node.js whatsapp-web.js Python 3.14 pandas smtplib Microsoft SMTP (Office 365) openpyxl Windows Task Scheduler
Impact
10k+
Students served by the system
60+
Courses across BBA, CSDA, AICS
~99%
Reduction in manual effort
<10s
End-to-end processing time

What's Next

The system has a clear upgrade path that will make it even more capable:

This project demonstrates that operational automation doesn't require a dedicated engineering team โ€” it requires identifying the right problem, choosing the right tools, and building something that actually gets used.

View All Case Studies Hire Me