AI Assistant
40ad46c026
fix: Parse wizard_plan from edit_fields_parsed structure
Problem:
- wizard_plan comes in nested structure: edit_fields_parsed.wizard_plan_parsed
- Old SQL looked for wizard_plan at root level (partial.p->'wizard_plan')
- Result: wizard_plan was always NULL even though it existed in payload
Solution:
- Updated wizard_plan_parsed CTE to check multiple locations:
1. edit_fields_parsed.wizard_plan_parsed (already parsed object) ✅
2. edit_fields_raw.body.wizard_plan (escaped JSON string)
3. Root level wizard_plan (backward compatibility)
4. Database fallback (if not in payload)
- Updated wizard_answers_parsed CTE:
1. edit_fields_raw.body.wizard_answers (string) ✅
2. edit_fields_parsed.body.wizard_answers (string)
3. Root level (backward compatibility)
- Updated session_id, unified_id, contact_id, phone extraction:
COALESCE() checks edit_fields_parsed.body and edit_fields_raw.body
Input structure from n8n workflow form_get:
{
"payload_partial_json": {
"edit_fields_parsed": {
"wizard_plan_parsed": {...}, ← TARGET
"body": {
"session_id": "sess_xxx", ← ALSO HERE
"unified_id": "usr_xxx",
"wizard_answers": "{...}"
}
}
}
}
Now: wizard_plan preserves correctly when uploading files ✅
2025-11-21 16:10:57 +03:00
..
2025-11-21 15:57:18 +03:00
2025-11-20 18:31:42 +03:00
2025-11-21 15:57:18 +03:00
2025-11-21 15:57:18 +03:00
2025-11-20 18:31:42 +03:00
2025-11-20 18:31:42 +03:00
2025-11-20 18:31:42 +03:00
2025-11-20 18:31:42 +03:00
2025-11-21 15:57:18 +03:00
2025-11-19 18:46:48 +03:00
2025-11-20 18:31:42 +03:00
2025-11-21 15:57:18 +03:00
2025-11-21 15:57:18 +03:00
2025-11-21 15:57:18 +03:00
2025-11-21 15:57:18 +03:00
2025-11-20 18:31:42 +03:00
2025-11-21 15:57:18 +03:00
2025-11-21 15:57:18 +03:00
2025-11-21 15:57:18 +03:00
2025-11-19 18:46:48 +03:00
2025-11-19 18:46:48 +03:00
2025-11-21 15:57:18 +03:00
2025-11-19 18:46:48 +03:00
2025-11-21 15:57:18 +03:00
2025-11-21 15:57:18 +03:00
2025-11-21 15:57:18 +03:00
2025-11-21 15:57:18 +03:00
2025-11-21 15:57:18 +03:00
2025-11-20 18:31:42 +03:00
2025-11-20 18:31:42 +03:00
2025-11-21 16:10:57 +03:00
2025-11-21 15:57:18 +03:00
2025-11-19 18:46:48 +03:00
2025-11-21 15:57:18 +03:00
2025-11-19 18:46:48 +03:00
2025-11-19 18:46:48 +03:00
2025-11-19 18:46:48 +03:00
2025-11-19 18:46:48 +03:00
2025-11-21 15:57:18 +03:00
2025-11-19 18:46:48 +03:00
2025-11-19 18:46:48 +03:00
2025-11-21 15:57:18 +03:00
2025-11-19 18:46:48 +03:00