Appearance
Luồng Enrichment, Routing & Assignment
Cập nhật: 2026-05-10 | Source of truth: Production scripts trên haravan.help
Tổng quan luồng
1. Tạo ticket
Nhánh A: Onboarding API
- Script:
Onboarding - Create Ticket API - Input:
company_name,customer_email,contact_phone,custom_store_url - Idempotency: theo
custom_bitrix_deal_id
Nhánh B: Agent tạo từ dialog
- Client:
Onboarding - Agent Ticket Dialog - API:
Onboarding - Agent Ticket API - Input:
customer_email,contact_phone,custom_store_url,subject,description,custom_product_suggestion
Nhánh C: Portal/email thông thường
- Ticket đi theo flow Helpdesk chuẩn
- Không có hard validation bắt buộc customer/store_url
2. Validation (trước khi lưu)
| Script | Hành vi | Blocking? |
|---|---|---|
| Contact Phone Validate | Normalize số điện thoại best-effort | ❌ Không chặn |
| Normalize Intake Selects | Dọn giá trị select stale/invalid | ❌ Không chặn |
| Product Suggestion Map | Map suggestion → product_line + product_feature | ❌ Không chặn |
Nguyên tắc
Tất cả validation hiện tại đều non-blocking — không bao giờ chặn tạo ticket.
3. Làm giàu dữ liệu (Enrichment)
Tự động sau save
Script: Auto Customer Sync From OrgID (After Save)
- Parse và normalize
custom_store_url/domain - Gọi
meta.jsontheo host hợp lệ để lấy orgid (meta-first) - Fallback: đọc field legacy, scan subject/description
- Domain guard: bỏ qua domain dễ nhầm (google.com, shopify.com, ...)
- Ngoại lệ:
myharavan.comvà*.myharavan.comluôn được xử lý - Tìm
HD Customertheo orgid/domain (local-first) - Bitrix chỉ gọi khi local thiếu dữ liệu routing
Segment mapping
| Nguồn | Giá trị | Segment |
|---|---|---|
Bitrix UF_CRM_1778130421650 | 15090 | SME |
Bitrix UF_CRM_1778130421650 | 15092 | Medium |
Bitrix UF_CRM_1778130421650 | 15094 | Enterprise |
HSI 500+ hoặc shopplan Grow/Scale | — | Medium |
| Fallback | — | SME |
4. Routing (Normalize → agent_group)
Quy tắc quan trọng
custom_service_grouplà Select field (CODE:Ecom,Ads,Design...)agent_grouplà Link field (tên team:Service Ecom,CS 60p,Sale...)- Script routing là layer mapping duy nhất: CODE
Ecom→ teamService Ecom - Chỉ route sang
Service Ecomkhi có 3 điều kiện AND:custom_service_group == "ecom"(lowercase exact)- Có
customerhoặccustom_orgid(basic evidence) - Có
custom_partner_servicehoặccustom_current_shopplan(Bitrix evidence)
- Thiếu evidence → fallback
CS 60p
5. Assignment Rules
| Rule | Priority | Điều kiện |
|---|---|---|
| Partner - ... - Support Rotation | Cao nhất | agent_group == "Partner - ..." |
| AR02 - SME 9M Scale | 300 | agent_group == "Medium - Scale" |
| AR03 - SME 9M Grow | 200 | agent_group == "Medium - Grow" |
| AR04 - CS60p Fallback | 100 | agent_group == "CS 60p" |
6. Lưu ý vận hành
- First insert vs re-save: First insert có thể thiếu evidence (enrichment chưa xong), re-save sẽ có đầy đủ
- Bitrix fail → graceful fallback: Bitrix down → 2 field business rỗng → gate fail → CS 60p
- AI không route trực tiếp: AI có thể ghi
custom_service_groupnhưng routing yêu cầu Bitrix evidence - Không dùng
doc.save()trong After Save — chỉfrappe.db.set_value(update_modified=False)
Tham chiếu
- Script Catalog — Registry đầy đủ
- safe_exec Gotchas — Lưu ý RestrictedPython
- Data Model — Entity và field contracts