
Designing Deterministic Outputs From Unstructured Messages
Your users send messy, unstructured text. Your backend expects clean, validated JSON. Bridging that gap is the hard part — and most teams get it wrong. This article walks through how to turn a raw WhatsApp message into a structured payload your application can safely act on. The Problem A real message from a hotel guest: hey can u move bk-4521 to fri plzz?? also ned more towls in rm 312 thx Typos. Abbreviations. Two requests in one message. No punctuation. Your PMS expects: { "booking_ref" : "BK-4521" , "new_date" : "2026-03-14" , "room" : "312" , "items" : [ "extra towels" ] } How do you get from A to B — reliably? Step 1: Define Your Schema Before touching any LLM, define what your backend expects. This is your contract. { "intent" : "string (enum)" , "actions" : [ { "type" : "string (action identifier)" , "payload" : { "field_1" : "string | number | null" , "field_2" : "string | number | null" } } ], "confidence" : "number (0-1)" , "suggested_reply" : "string | null" } Key principle
Continue reading on Dev.to Webdev
Opens in a new tab




