Sorting website form enquiries with an LLM that can only answer from a list
说明与用途
一个小型 n8n 工作流使用 LLM 将网站表单查询分类为固定列表中的类别,并将结果记录在 Google 表格中,任何非精确匹配的请求将被标记为需要人工审核。
问题
Contact forms generate varied enquiries that must be categorized; free‑form LLM responses cause inconsistent categories and break spreadsheet filters.
结果
The workflow correctly logs 17 test cases, handling valid categories, nulls, invented IDs, sentences, HTTP 500 errors, braces in text, and invalid emails, ensuring each valid request produces exactly one row and no external hosts are contacted.
工作流
- Receive form POST via webhook (name, email, company, message).
- Normalize data; if email invalid, return HTTP 400 and abort.
- Send to LLM a prompt containing the list of category IDs and the enquiry text.
- Receive LLM reply; trim, lowercase, strip quotes and trailing period.
- Check if reply exactly matches one of the predefined IDs.
- If match, write row to Google Sheets with category; if not, write row with needs_human flag and check_notes.
- Return HTTP 200 with the category to the form webhook.
证据
So I built a small n8n workflow where the model gets a fixed list of category ids and may answer with one of them or null.
The model's reply gets trimmed, lowercased, and stripped of quotes and a trailing full stop.
I ran it on a real n8n 1.123.87 instance with local stand‑ins for the OpenAI and Google Sheets APIs, and 17 checks passed: correct categories logged for sales and support enquiries...
- 记录日期: 2026-11-01T05:13:43.225Z