Sakda101's picture
Reorder consultation tracking fields
3835fc2
Raw History Blame Contribute Delete
12.5 kB
{% extends "base.html" %}
{% block title %}Consultants - Explorer{% endblock %}
{% block nav_consultants %}active{% endblock %}
{% block head %}
<script>
const SERVICES_MAP = {{ services_json | safe }};
const TYPE_CLUSTER = {{ type_cluster_json | safe }};
const GROUP_INTERNAL = {"VISA - KHMER":"VISA - KH","VISA - FOREIGNER":"VISA-FOR"};
</script>
{% endblock %}
{% block content %}
<div class="page-header consultants-header">
<div class="page-header-text">
<div class="page-eyebrow">Objection Analyzer</div>
<h1 class="page-title">Decode the <em>real</em> concern.</h1>
<p class="page-subtitle">Select the exact visa service from the active matrix, paste a customer objection, and the AI returns the matching type and cluster. Responses stay blank until they are filled in Browse.</p>
</div>
<div class="page-header-actions consultants-actions">
<button type="button" class="btn btn-outline btn-sm" onclick="document.getElementById('consultant-tips').open = !document.getElementById('consultant-tips').open">Tips</button>
<a href="/analytics" class="btn btn-outline btn-sm">History</a>
</div>
</div>
<div class="consultants-workspace">
<section class="card consultant-input-card" id="analyzer-form">
<div class="consultant-card-title">Customer context</div>
<div class="consultant-context-grid">
<div class="field consultant-customer-name-field">
<label class="field-label" for="customer-name">Customer Name</label>
<input id="customer-name" class="input" type="text" placeholder="Type customer name" maxlength="120" />
</div>
<div class="field">
<label class="field-label" for="customer-group">Group</label>
<select id="customer-group" class="select" onchange="updateServiceDropdown()">
{% for g in group_labels %}
<option value="{{ g }}">{{ g }}</option>
{% endfor %}
</select>
</div>
<div class="field">
<label class="field-label" for="visa-service-search">Service</label>
<div class="service-combobox" id="service-combobox">
<input type="hidden" id="visa-service" value="" />
<input id="visa-service-search" class="input" type="text"
placeholder="Select a service"
autocomplete="off"
oninput="filterServiceOptions()"
onfocus="openServiceOptions()" />
<div id="visa-service-options" class="service-options" hidden></div>
</div>
</div>
</div>
<div class="consultant-card-title consultant-tracking-title">Objection tracking</div>
<div class="consultant-tracking-grid">
<div class="field">
<label class="field-label" for="objection-status">Objection Status</label>
<select id="objection-status" class="select">
<option value="Unsolved">Unsolved</option>
<option value="Solved">Solved</option>
</select>
</div>
<div class="field">
<label class="field-label" for="main-contact-platform">Main Contact Platform</label>
<select id="main-contact-platform" class="select">
<option value="">Select a platform</option>
<option value="Explorer Webapp">Explorer Webapp</option>
<option value="Explorer by SL">Explorer by SL</option>
<option value="Explorer Travel Agency">Explorer Travel Agency</option>
</select>
</div>
<div class="field">
<label class="field-label" for="objection-date">Objection Date</label>
<input id="objection-date" class="input consultant-date-input" type="text" inputmode="none" autocomplete="off" readonly placeholder="Select date" data-themed-date="true" />
</div>
<div class="field">
<label class="field-label" for="first-contact-date">First Contact Date</label>
<input id="first-contact-date" class="input consultant-date-input" type="text" inputmode="none" autocomplete="off" readonly placeholder="Select date" data-themed-date="true" />
</div>
<div class="field">
<label class="field-label" for="ad-source">Ad Source</label>
<input id="ad-source" class="input" type="text" placeholder="Type ad source" maxlength="120" />
</div>
<div class="field">
<label class="field-label" for="lead-quality">Lead Quality</label>
<select id="lead-quality" class="select">
<option value="">Select lead quality</option>
<option value="Qualified">Qualified</option>
<option value="Not Qualified">Not Qualified</option>
<option value="Lost">Lost</option>
<option value="Converted">Converted</option>
<option value="Intake">Intake</option>
<option value="Awaiting Documents">Awaiting Documents</option>
</select>
</div>
</div>
<div class="consultant-card-title consultant-quote-title">Customer quote</div>
<div class="field">
<textarea id="quote" class="textarea consultant-quote-box" rows="6"
placeholder="Paste the customer's exact words. e.g. &quot;Why are you so expensive compared to other agencies on Norodom?&quot;"
maxlength="2000"></textarea>
<div class="consultant-quote-meta">
<span id="quote-readiness">Minimum 10 characters</span>
<span id="char-counter">0 / 2000</span>
</div>
</div>
<div id="input-error" class="alert alert-error mt-1" hidden></div>
<button id="analyze-btn" class="btn btn-primary btn-lg btn-block consultant-analyze-btn" onclick="runPredict()">
Analyze objection
</button>
<div class="consultant-examples">
<div class="consultant-example-label">Try an example</div>
<button type="button" class="consultant-example" data-example="Why is your fee 1,200 USD when the agency on Norodom is only 800?">
"Why is your fee 1,200 USD when the agency on Norodom is only 800?"
</button>
<button type="button" class="consultant-example" data-example="I'm not sure I trust you with my passport for that long.">
"I'm not sure I trust you with my passport for that long."
</button>
<button type="button" class="consultant-example" data-example="My friend got rejected last year - what if the same thing happens to me?">
"My friend got rejected last year - what if the same thing happens to me?"
</button>
<button type="button" class="consultant-example" data-example="Can I just submit the application myself to save the consultancy fee?">
"Can I just submit the application myself to save the consultancy fee?"
</button>
</div>
</section>
<section class="consultant-output-column">
<div id="result-placeholder" class="consultant-placeholder-card">
<div class="consultant-placeholder-mark">✦</div>
<h2>Awaiting your customer quote.</h2>
<p>
The model has been trained on <strong>4,400+</strong> real Explorer by SL chats.
Paste a verbatim objection on the left to receive a structured breakdown and the perfect bilingual response.
</p>
</div>
<div id="no-objection-panel" class="no-objection-card consultant-output-card" hidden>
<div class="card-header-title">No customer objection detected</div>
<div id="no-objection-message" class="no-objection-title">This quote does not contain a customer objection.</div>
<div class="no-objection-copy">
Paste a customer concern about price, documents, processing time, trust, location, or visa risk before running the analyzer.
</div>
<div id="no-objection-quote" class="no-objection-quote"></div>
</div>
<div id="result-panel" class="consultant-result-panel" hidden>
<div id="correction-banner" class="correction-banner" hidden>
<strong>Prediction improved by staff correction</strong>
</div>
<div class="card result-quote consultant-result-quote mb-2">
<div>
<div class="card-header-title mb-1">Customer quote</div>
<div id="result-quote-text" class="result-quote-text"></div>
</div>
<div id="result-badges" class="result-badges"></div>
</div>
<div class="grid-3 mb-2 consultant-result-grid">
<div class="card card-tight">
<div class="card-header-title">Objection type</div>
<div id="result-type" class="result-value-big mt-2"></div>
<div id="result-type-conf"></div>
</div>
<div class="card card-tight">
<div class="card-header-title">Cluster</div>
<div id="result-cluster" class="result-value-big mt-2"></div>
<div id="result-cluster-conf"></div>
</div>
<div class="card card-tight">
<div class="card-header-title">Severity</div>
<div id="result-severity" class="mt-2"></div>
<div id="result-video" class="result-meta mt-2"></div>
</div>
</div>
<div class="card result-highlight consultant-perfect-card mb-2">
<div class="consultant-perfect-head">
<div class="card-header-title">Perfect response</div>
<button type="button" class="btn btn-outline btn-sm" onclick="copyPerfectResponse()">Copy</button>
</div>
<div id="result-response" class="result-value mt-2"></div>
</div>
<details class="consultant-extra-details mb-2">
<summary>More response details</summary>
<div class="grid-2 mt-2">
<div class="card">
<div class="card-header-title">Recommended solution</div>
<div id="result-solution" class="result-value mt-2"></div>
</div>
<div class="card">
<div class="card-header-title">Follow-up question</div>
<div id="result-followup" class="result-value mt-2"></div>
</div>
</div>
</details>
<div id="no-response-warn" class="alert alert-info" hidden>
This service and objection exists in the Browse matrix, but its response has not been filled yet.
Add the English and Khmer response from the Browse page when it is ready.
</div>
<div id="service-objection-warn" class="alert alert-info" hidden>
This objection does not exist for this visa service
</div>
<div class="card" id="feedback-section">
<div class="card-header-title">Was this prediction correct?</div>
<div class="flex gap-1 mt-2" id="feedback-btns">
<button class="btn btn-outline" onclick="feedbackYes()">Yes, correct</button>
<button class="btn btn-outline" onclick="feedbackNo()">No, fix it</button>
</div>
<div id="feedback-msg" hidden style="margin-top:0.75rem;font-size:0.9rem;"></div>
<div id="correction-form" hidden style="margin-top:1.5rem; padding-top:1.25rem; border-top:1px solid var(--border);">
<div class="card-header-title text-gold mb-2">Correct the prediction</div>
<div class="grid-2">
<div class="field">
<label class="field-label">Correct Objection Type</label>
<select id="correct-type" class="select" onchange="updateClusterOptions()"></select>
</div>
<div class="field">
<label class="field-label">Correct Cluster</label>
<select id="correct-cluster" class="select"></select>
</div>
</div>
<div class="flex gap-1 mt-2">
<button class="btn btn-primary" onclick="submitCorrection()">Submit correction</button>
<button class="btn btn-outline" onclick="cancelCorrection()">Cancel</button>
</div>
</div>
</div>
<details id="consultant-tips" class="tips-details mt-2">
<summary>Tips for getting the best results</summary>
<div class="tips-body card mt-1">
<ul class="tips-list">
<li><strong>Paste the customer's exact words.</strong> The model was trained on real Explorer by SL chat data - phrasing matters.</li>
<li><strong>One objection at a time.</strong> If a customer raises two concerns, analyze each separately.</li>
<li><strong>Include context if possible.</strong> Selecting the visa type and destination helps the response lookup.</li>
<li><strong>Wrong prediction?</strong> Click <em>No, fix it</em> to submit a correction. The system learns from every correction.</li>
</ul>
</div>
</details>
</div>
</section>
</div>
{% endblock %}