Fire Live Agent Hints From Phrases in a Streaming Transcript
Last updated: November 29, 2026
Quick Overview
Build a component that receives a live transcript one word at a time and returns, after each word, every configured trigger phrase that just completed, suppressing a phrase that already fired within the last K words.
Cresta
November 29, 20260
0
0 solved
Build a component that receives a live transcript one word at a time and returns, after each word, every configured trigger phrase that just completed, suppressing a phrase that already fired within the last K words.
Cresta's real-time agent assist reacts to what the customer says mid-call, so matching many configured phrases against a word stream with constant work per word is a realistic building block. The interviewer looks for a multi-pattern matcher (trie with failure links) instead of rescanning a sliding window, plus sensible debounce semantics.
What the Interviewer Expects
- Recognize that naive per-word rescans cost O(total phrase length) per token
- Build Aho-Corasick over word tokens with output links so nested phrases fire
- Keep matcher state between calls so it works on a stream
- Implement a cooldown per phrase
- Discuss normalization (case, punctuation, ASR casing)
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- ASR partials revise earlier words; how would you handle a retraction of the last two tokens?
- How would you support fuzzy matches such as plural forms or a dropped filler word?
- How would you shard thousands of tenant-specific phrase sets in one service?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Phrases are word sequences like "cancel my account". Input arrives as single tokens. After each token, return phrases ending at that token. A phrase that fired fewer than cooldown tokens ago is supp...
High-Level Design
Build a trie of word tokens. Add failure links by BFS so that on a mismatch we fall back to the longest proper suffix that is also a trie prefix, and union output lists along failure links so nested p...