AI Intent Router — Classify and Route Messages to Different Handlers

I built an AI intent router workflow that classifies incoming messages and routes them to different handlers based on the detected intent.

What it does

A single webhook receives any message. An AI classifier (gpt-4o-mini via OpenRouter) determines the intent — support, sales, billing, feedback, or general — and routes it to the appropriate handler.

Architecture

  1. Webhook Trigger — receives POST with {"message": "your text here"}
  2. Code Node — builds the classification prompt
  3. HTTP Request — calls OpenRouter/OpenAI for intent classification
  4. Code Node — parses the AI response into structured JSON
  5. Respond to Webhook — returns the classified intent with confidence score

Why this approach?

  • HTTP Request > langchain nodes for the classifier. More reliable, easier to debug, and you can use any OpenAI-compatible API.
  • gpt-4o-mini is plenty for classification — fast and cheap (~$0.15/1M tokens).
  • JSON output parsing with fallback — if the AI returns bad JSON, it falls back to keyword matching.

Example response

{
  "status": "routed",
  "intent": "BILLING",
  "confidence": 0.9,
  "summary": "Payment failure and refund request.",
  "handler": "billing_team",
  "originalMessage": "My payment failed and I need a refund"
}

Tested with 5 different message types — all classified correctly.

The workflow JSON is available free at turtletools.app. Happy to answer questions about the implementation!

1 Like

That is actually smart! Nice job!