<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Midhun P M</title>
    <description>The latest articles on DEV Community by Midhun P M (@midhun_pm_4f9bc1f20dbd1c).</description>
    <link>https://dev.to/midhun_pm_4f9bc1f20dbd1c</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4059008%2F7d261f25-a34d-4a27-a394-beb71b2bb386.jpg</url>
      <title>DEV Community: Midhun P M</title>
      <link>https://dev.to/midhun_pm_4f9bc1f20dbd1c</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/midhun_pm_4f9bc1f20dbd1c"/>
    <language>en</language>
    <item>
      <title>I Built a WhatsApp AI Agent for Kochi Metro — Here's How It Works</title>
      <dc:creator>Midhun P M</dc:creator>
      <pubDate>Sun, 02 Aug 2026 11:29:14 +0000</pubDate>
      <link>https://dev.to/midhun_pm_4f9bc1f20dbd1c/i-built-a-whatsapp-ai-agent-for-kochi-metro-heres-how-it-works-3k4a</link>
      <guid>https://dev.to/midhun_pm_4f9bc1f20dbd1c/i-built-a-whatsapp-ai-agent-for-kochi-metro-heres-how-it-works-3k4a</guid>
      <description>&lt;p&gt;How I built MetroMind, a WhatsApp-based agentic AI commute assistant&lt;br&gt;
for Kochi Metro using n8n, FastAPI, LangChain, and GTFS data — and placed Top 10&lt;br&gt;
at the OpenAI Codex Nightline Hackathon.&lt;/p&gt;

&lt;h2&gt;
  
  
  canonical_url: &lt;a href="https://midhunpm.in" rel="noopener noreferrer"&gt;https://midhunpm.in&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Real talk — Kochi Metro's app is terrible. You open it, wait for it to load,&lt;br&gt;
tap through four screens, and by that time you've already missed your train.&lt;/p&gt;

&lt;p&gt;So I built &lt;strong&gt;MetroMind&lt;/strong&gt; — a WhatsApp AI agent that handles your entire Kochi&lt;br&gt;
Metro commute through a chat. No app switching, no loading screens. Just message&lt;br&gt;
it like you'd message a friend.&lt;/p&gt;

&lt;p&gt;It placed &lt;strong&gt;Top 10 at the OpenAI Codex Nightline Hackathon&lt;/strong&gt;. Here's how it works.&lt;/p&gt;




&lt;h2&gt;
  
  
  What MetroMind Does
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Route planning&lt;/strong&gt; — "How do I get from Aluva to MG Road?" and it tells you
exactly which trains, interchanges, and timings&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fare calculation&lt;/strong&gt; — real fares pulled from live GTFS data, not hardcoded guesses&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ticket booking&lt;/strong&gt; — automated via Playwright since KMRL doesn't have a public
booking API (more on this below)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Natural language&lt;/strong&gt; — ask it anything in plain English or Malayalam, it figures
out what you need&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All through WhatsApp. No app install required.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Stack
&lt;/h2&gt;

&lt;p&gt;WhatsApp (Twilio) → n8n → FastAPI → LangChain → GTFS Data&lt;br&gt;
↓&lt;br&gt;
Playwright (booking automation)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;n8n&lt;/strong&gt; as the orchestration layer — handles the WhatsApp webhook from Twilio,
routes messages, manages conversation state&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;FastAPI&lt;/strong&gt; backend — core business logic, GTFS parsing, route calculation&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LangChain&lt;/strong&gt; — agent layer that interprets user intent and decides which tools
to call&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GTFS&lt;/strong&gt; — Kerala's open transit data format, has all station info, routes,
and schedules&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Twilio&lt;/strong&gt; — WhatsApp Business API for the messaging interface&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  The Interesting Part — Reverse Engineering KMRL's API
&lt;/h2&gt;

&lt;p&gt;KMRL doesn't have a public booking API. Their app encrypts all traffic with AES.&lt;/p&gt;

&lt;p&gt;So I reverse engineered it.&lt;/p&gt;

&lt;p&gt;Decompiled the APK, traced the encryption keys, figured out the request/response&lt;br&gt;
format. Then built a Playwright-based automation that handles the booking flow&lt;br&gt;
headlessly — it's essentially a bot that fills out the booking form faster than&lt;br&gt;
a human can.&lt;/p&gt;

&lt;p&gt;Not the cleanest solution, but it works. And it's way faster than doing it manually.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why n8n Instead of Just FastAPI
&lt;/h2&gt;

&lt;p&gt;I self-host n8n on my homeserver (Dell i5, Ubuntu 24.04, behind Cloudflare Tunnel&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Traefik). Using n8n meant I could:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Visually wire up the WhatsApp → agent → response pipeline&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add new triggers and integrations without touching code&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Monitor every workflow run with full execution logs&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a project that's fundamentally about orchestration, a visual orchestration&lt;br&gt;
tool made a lot of sense.&lt;/p&gt;




&lt;h2&gt;
  
  
  What I'd Do Differently
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;GTFS data freshness&lt;/strong&gt; — KMRL updates their GTFS feed inconsistently. I ended&lt;br&gt;
up having to manually refresh it. A proper cron job with a diff check would've&lt;br&gt;
been cleaner.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Session management&lt;/strong&gt; — WhatsApp conversations don't have a native session&lt;br&gt;
concept. I hacked around it with n8n's static data but a proper Redis session&lt;br&gt;
store would've been better.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The AES reverse engineering&lt;/strong&gt; — fun to do, nightmare to maintain. If KMRL&lt;br&gt;
ever updates their app, the whole booking flow breaks. A proper API partnership&lt;br&gt;
would obviously be ideal.&lt;/p&gt;




&lt;h2&gt;
  
  
  Try It / Source
&lt;/h2&gt;

&lt;p&gt;The project is part of my portfolio at &lt;strong&gt;&lt;a href="https://midhunpm.in" rel="noopener noreferrer"&gt;midhunpm.in&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I'm Midhun, a CS undergrad at Sahrdaya College of Engineering building AI agents&lt;br&gt;
and full-stack systems. If you're working on something similar or want to talk&lt;br&gt;
transit tech, AI agents, or self-hosted infrastructure — find me on&lt;br&gt;
&lt;a href="https://www.linkedin.com/in/midhun-pm-b947a1279/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; or&lt;br&gt;
&lt;a href="https://github.com/9MidhunPM" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Built with n8n, FastAPI, LangChain, Twilio, Playwright, and way too much&lt;br&gt;
curiosity about how KMRL's app actually works.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>python</category>
      <category>webdev</category>
      <category>showdex</category>
    </item>
  </channel>
</rss>
