We recently built a sales order tracking system in Retool for a manufacturing client. One problem we ran into: employees were spending hours copying data from customer emails into the system, and half of those steps were just repetitive text cleanup.
Instead of adding more manual forms, we set up a Retool Workflow that calls an OpenAI API. Here’s the flow:
- Incoming email gets saved in Postgres (we store subject, body, and attachments).
- Retool Workflow triggers whenever a new row is inserted.
- Inside the Workflow, we pass the email body to Retool AI with a structured system prompt like:
"Extract customer name, order quantity, and product code. Return valid JSON." - The response is parsed with
JSON.parse()in a JS block. If the AI messes up and returns invalid JSON, we run a quick regex cleanup before retrying. - The cleaned result is inserted back into our
orderstable.

We could have also pulled emails directly from Gmail with the Gmail API and set a Workflow to run every X minutes, but this setup (triggering on DB insert) makes it effectively real-time, which worked better for order intake.
Now in the Retool app, employees just see a pre-filled order form that’s 90% complete. They only correct edge cases instead of typing everything.
Retool bits worth noting:
- Workflows make this easy since you can add retries and error handling with branches.
- Using the built-in JSON Schema validator in Retool helps catch bad AI output before it hits the DB.
- We keep the prompt very literal, if you try to be fancy, the AI drifts and your Workflow breaks.
- We also tested retool Classify Text option, but in our experience a custom prompt gave us more flexibility
This reduced order entry time by half, and we didn’t have to build a big external service.


Leave a Reply