Text Testing
Text testing runs RubricHQ’s AI-simulated caller against your agent over text instead of voice. It’s ~10× faster and far cheaper than voice testing — ideal for workflow validation, regression suites, and CI.
Configure it under Agent → Channels → Text Channel and pick a Connection type:
RubricHQ is the client in both cases — it connects out to your agent; your agent never connects to RubricHQ. When the conversation ends, RubricHQ records the transcript, who ended it and why, and evaluates your metrics automatically.
Chat-only bots don’t need a phone number. If the Text channel is the only channel you enable, the phone number field becomes optional. Add a phone number or web channel later and the same agent can be tested over voice too — see Testing a voice agent over text.
Custom WebSocket
What you set in RubricHQ (Agent → Channels → Text Channel)
These are values you enter once in the RubricHQ dashboard for the agent:
What RubricHQ sends to your server on connect
RubricHQ includes all of these HTTP headers on every connection (the X-… row is the only conditional one — it appears only when the scenario has matching metadata). You must validate X-RUBRIC-SECRET; the others identify the agent / scenario / run so you can route and correlate.
Messages — RubricHQ → your agent
Standard user turn:
End signal (RubricHQ ended the conversation — the simulated customer was done, or the scenario hit its turn limit). metadata.end_reason says why:
After sending it, RubricHQ closes the connection. Treat it like the customer closing the chat window.
Messages — your agent → RubricHQ
Standard agent reply:
Reply with metadata (merged into the run, last-write-wins; not a turn on its own):
Metadata-only frame (recorded, not treated as a turn):
Function call + result (recorded in the transcript as function_call / function_call_result, not treated as a turn — keep streaming until you send the actual reply):
End the conversation — send your closing line with type: "end_call", optionally with a reason (recorded on the run as bot_ended:<reason>):
…or simply close the socket — RubricHQ records that as bot_disconnected. Sending end_call is better: your closing line lands in the transcript and the reason is kept.
Agents that speak first
If your agent greets the customer as soon as the connection opens (as most voice agents do), just send the greeting — RubricHQ waits about 3 seconds after connecting, records your greeting as the first turn, and the simulated customer replies to it. If nothing arrives, the simulated customer opens the chat instead.
Lifecycle & timeouts
- Either side may end via
{"type": "end_call"}, or your server can close the socket. See How a conversation ends. - Turn limit — each scenario has a maximum number of turns. If neither side has ended the chat by then, RubricHQ ends it and sends
end_callwithend_reason: max_turns_reached. - Per-turn idle timeout — if your agent doesn’t reply within Per-turn timeout, the run ends
failed(ended_reason: agent_timeout) with the partial transcript saved. - Max session duration — the whole conversation is capped; exceeding it ends the run
failed(max_duration). - A failed connection ends the run
connection_failed; a mid-conversation drop ends itconnection_lost.
A quick conversation (WebSocket)
A full session looks like this — each line is one frame; the label shows who sent it:
A run with a function call looks the same, but the agent streams the call/result frames before its spoken reply (they’re recorded in the transcript but don’t count as a turn):
Local development: expose your local server with a tunnel (e.g. ngrok) and use the wss:// URL in the WebSocket URL field.
Your reply comes from your agent
Your agent’s reply is produced by your real agent — an LLM, a Pipecat pipeline, a LangChain chain, your own model and tools. The WebSocket handler is only a thin bridge:
receive {"content": user_text} → your agent (LLM + your context / tools / state) → send {"content": reply}
So making an existing agent “WebSocket-ready” is just adding that bridge around your real brain. If your agent is built on Pipecat, you already have an LLM context and pipeline — feed the incoming text into your context, run the pipeline (text in → text out), and send the assistant’s text back. A full Pipecat reference ships in the voice-pipecat project, custom_ws_pipecat_agent.py: a real OpenAILLMContext + OpenAILLMService pipeline bridged to this protocol (vs. custom_ws_agent.py, the minimal hand-rolled version).
Example: a Pipecat agent
If your agent is a Pipecat pipeline, the bridge is small — push each incoming content into your LLM context, run the pipeline, and send the assistant’s text back:
That’s the heart of the full reference custom_ws_pipecat_agent.py, which additionally routes on X-RUBRIC-AGENT-ID and parses inline <dtmf/> tags. Any other framework (LangChain, your own model) follows the same shape: content in → your agent → content out.
REST — OpenAI-compatible
If your bot already speaks the OpenAI Chat Completions format, point RubricHQ at it — no bridge code needed.
What you set in RubricHQ (Agent → Channels → Text Channel → REST)
What RubricHQ sends each turn
One POST per customer message, carrying the whole conversation so far (user = the simulated customer, assistant = your bot’s earlier replies):
RubricHQ sends only messages — your server picks the model. Reply with a normal chat completion:
Keep state per conversation, not per request. If your bot’s tools change things (cancel an order, issue a refund), key that state on X-RUBRIC-RUN-ID — it’s the same for every turn of one test conversation.
Ending the chat over REST
HTTP has no socket to close, so both sides say it explicitly.
Your bot ends the chat — include any one of these in the response; the reply text is recorded as your closing line:
end_reason (top level) is optional and recorded on the run as bot_ended:<reason>.
RubricHQ ends the chat — when the simulated customer is done or the turn limit is hit, RubricHQ sends one last POST to the same URL. Recognise it by the X-RUBRIC-EVENT: end_call header (or "type": "end_call" in the body), close the conversation on your side, and return any 2xx — the response body is ignored and your model doesn’t need to run:
RubricHQ’s REST transcripts contain the messages only. If you want tool calls to appear in the transcript (and be available to your metrics), use the WebSocket connection, which streams Function Call frames.
How a conversation ends
When does it close?
A test conversation stops at the first of these:
There is no other hidden cap: a WebSocket stays open between turns until one of the above happens, and over REST nothing is held open between requests.
Who ended it
Every text run ends with a named ender, stored on the run as ended_by and ended_reason. Exactly one side always ends it: your bot, or RubricHQ’s simulated customer (which also enforces the turn limit).
Runs in the system rows are marked failed; the others complete and are evaluated normally. Use ended_by to spot bots that never close a conversation (always test_agent) or that hang up too early (real_agent before the goal was met).
Testing a voice agent over text
A text run doesn’t care how your agent is normally reached. If you already test an agent over phone or web, you can test the same agent over text — same instructions, same tools — to iterate on its logic much faster:
- Expose a text endpoint for it (WebSocket or REST, as above). Most voice agents greet first; over WebSocket just send the greeting on connect.
Tip — one URL for both channels. Every text connection carries
X-RUBRIC-CHANNEL: text, so you can keep the agent’s existing voice WebSocket URL (e.g.wss://bot.example.com/ws?agent_id=nora) and branch on that header: no header → run your voice pipeline,text→ run the same agent in text mode. Same URL, same agent name, sameX-RUBRIC-SECRET. - In RubricHQ, open the agent and enable the Text channel alongside its voice channels.
- Mark the scenarios you want to reuse as testing type Text or Both.
- Start a batch with testing mode Text.
Transcript metrics (policy, compliance, resolution, custom judges) run the same way on both channels, so you can compare a scenario’s text and voice results side by side. Audio metrics are skipped on the text runs.
DTMF (keypad input)
When a scenario enables the send_dtmf tool, the simulated caller can “press keypad digits” during a text conversation. Rather than a separate frame, it sends the digits as an inline tag embedded in a normal text message:
Your agent should parse <dtmf digits=\"...\"/> out of the message content, treat the matched digits as the caller’s keypad entry, and strip the tag before handling the text. Valid characters are 0-9, *, and #. A simple regex works:
The full message (tag included) is recorded in the transcript, so DTMF entries are visible in the run results.
Testing multiple agents on one endpoint
In RubricHQ you create one agent per bot you want to test. If those bots share a single endpoint, your server still needs to know which bot a given request/connection is for. RubricHQ tells you in two ways — pick whichever fits:
Option A — Read the X-RUBRIC-AGENT-ID header. Every WebSocket connection (and every REST request) carries X-RUBRIC-AGENT-ID, the RubricHQ agent id. Map each agent id to your bot once (the id is stable per agent), then dispatch on the header:
Option B — Put the bot in the URL. Give each RubricHQ agent a distinct path or query as its WebSocket URL — works on the same host and port:
RubricHQ connects to exactly the URL configured for that agent, so your router reads the path/query and dispatches.
You can also attach your own identifier: any scenario metadata field whose name starts with X- is forwarded verbatim as a header, so e.g. a scenario field X-Bot-Id = billing arrives as the X-Bot-Id header. (Use this for per-scenario routing; use X-RUBRIC-AGENT-ID or the URL for per-agent routing.)
Validate X-RUBRIC-SECRET first, then route on X-RUBRIC-AGENT-ID (or the URL). The other headers (X-RUBRIC-SCENARIO-ID, X-RUBRIC-RUN-ID, X-RUBRIC-BATCH-ID) identify the specific scenario / run / batch within that agent.
Test your endpoint before going live
You don’t need to launch a full RubricHQ run to validate your endpoint. Three levels of dev testing:
1. Probe it yourself (no RubricHQ needed). This small script mimics exactly what RubricHQ sends — it connects with the X-RUBRIC-* headers, sends a few user turns, and prints every frame your agent returns. Point it at your wss:// URL (local or staging):
2. Dry-run one scenario in the app. Use Live Simulations to run a single scenario against your endpoint and watch the transcript and metrics live, instead of launching a full batch — ideal for the first real round-trip.
3. Local development. Expose your local server with a tunnel (e.g. ngrok http 8080) so RubricHQ — or the probe above — can reach wss://… while you iterate.
Once the probe and a single Live Simulation pass, you’re ready to run full batches in production.
Metrics on text runs
- Transcript / LLM metrics (compliance, resolution, custom LLM judges, etc.) run on text exactly as on voice.
- Audio metrics (latency, interruptions, WPM, voice clarity…) are automatically skipped for text — there’s no audio.
- When creating a custom metric, Applies to lets you choose Text and Voice conversations (default) or Text Conversation only. A text-only metric won’t run on voice; anything that runs on voice also runs on text.
Results
After a run completes you’ll see the transcript (including any function-call frames), the metric evaluations, and who ended the conversation and why (ended_by / ended_reason, see How a conversation ends). Text runs show no recording section.
A scenario’s pass/fail (call success) is based on its critical metrics. A critical metric the judge marks not applicable to that conversation — e.g. “verified identity before account access” on a chat that never touched an account — doesn’t count against the run.