Goal: Use the Filestack CDN text_sentiment
transform to score ticket text and convert those scores into a clear priority (P0–P4). The guide builds the UI block-by-block so each part is understandable and testable. A complete, ready-to-run index.html
is provided at the end.
What we’ll build
-
A small client-side app that:
-
Takes ticket text.
-
Calls
text_sentiment
over the Filestack CDN (URL format shown below). -
Displays the raw JSON (
Positive
,Negative
,Neutral
,Mixed
). -
Maps the scores to a support priority with configurable thresholds.
-
Visualizes the scores in bars for a quick at-a-glance view.
-
Security note: In production, sign policies server-side and avoid exposing secrets in the browser. This demo keeps everything in one file for clarity and fast iteration.
API URL: exact shape
Keep the structure below—matching the known-good format:
-
Wrap text with
%22
(double quotes) and URL-encode the text payload. -
The policy must permit the needed calls—
convert
covers most transforms;read
is commonly included. -
The signature must be generated with the same app as the API key.
Priority rules (editable)
Use simple defaults and tweak them in UI inputs:
-
Negative ≥ 0.70 → P0 (Critical)
-
Negative ≥ 0.40 → P1 (High)
-
Mixed ≥ 0.50 → P2 (Medium)
-
Neutral ≥ 0.60 → P3 (Low)
-
Else → P4 (Very Low)
These thresholds balance straightforward triage with enough nuance to catch frustration (Negative) and uncertainty (Mixed).
1) HTML skeleton (structure only)
Define where credentials, text input, thresholds, and results live—no behavior yet.
2) Light-mode styles (accessible, framework-free)
Readable defaults, subtle shadows, and components that don’t fight your content.
3) URL builder (one job: construct the request)
This matches the proven, working shape—including %22
around the text.
4) Priority engine (pure functions)
Decoupled from the DOM so it’s easy to test.
5) UI bindings (wire up inputs, fetch, and render)
Keep DOM work separate from logic for clarity.
Full demo (single-file index.html
)
Paste your API key / policy / signature, enter ticket text, and click Analyze. The UI shows the JSON and the computed priority. You can also copy the exact CDN request URL the page used.
This is identical to the blocks above, consolidated for quick use.
Production notes
-
Sign and proxy: Generate
policy
andsignature
on the server (HMAC-SHA256 over the policy JSON using your app secret). Send the client a short-lived token or proxy the request to keep secrets off the page. -
Policy permissions: Include
convert
(covers text transforms) andread
. Set a tight expiry. -
Monitoring: Log raw sentiment JSON with ticket IDs for audits and threshold tuning.
-
Routing: Tie P0/P1 to on-call, P2 to senior agents, P3/P4 to standard queue. Adjust thresholds to match your CS ops.
Extensions (for later)
-
CSV batch: Upload a CSV of ticket texts, append sentiment + computed priority, return a CSV.
-
Helpdesk hooks: Call the transform from your ticketing system’s webhook or automation rules.
-
Multi-language: Detect language first; route non-English tickets to the right locale team.
A Product Marketing Manager at Filestack with four years of dedicated experience. As a true technology enthusiast, they pair marketing expertise with a deep technical background. This allows them to effectively translate complex product capabilities into clear value for a developer-focused audience.
Read More →