Quickstart
You’ll send one finished conversation to Midwater and read back its outcome and check results. It takes about five minutes.
-
Make a test key. In the Midwater app, open Developers and create a key in the Test environment. It starts
mw_test_and is shown once, so copy it now. Test keys keep practice calls out of your live reports and alerts. -
Set two environment variables.
Terminal window export MIDWATER_API_KEY="mw_test_..."export MIDWATER_BASE_URL="<the base URL for your Midwater environment>"Every example in these docs reads the key and the base URL from these variables. The base URL has no default: use the one for your Midwater environment.
-
Send a conversation. When a call or chat ends, send its transcript, the agent that handled it, and what the agent did.
Terminal window curl -X POST "$MIDWATER_BASE_URL/v1/conversations" \-H "Authorization: Bearer $MIDWATER_API_KEY" \-H "Content-Type: application/json" \-H "Idempotency-Key: call_8f2a91" \-d '{"external_id": "call_8f2a91","channel": "voice","ended_by": "caller","agent": { "id": "front-desk", "name": "Front desk", "version": "1.0.0" },"transcript": [{ "speaker": "agent", "text": "Thanks for calling, this call may be recorded. How can I help?" },{ "speaker": "user", "text": "I need to move my appointment to Thursday." },{ "speaker": "agent", "text": "Sure, I have Thursday at 10 AM. Does that work?" },{ "speaker": "user", "text": "Yes, that is perfect." },{ "speaker": "agent", "text": "Great, you are all set for Thursday at 10 AM." }],"events": [{ "type": "tool_call", "name": "reschedule_appointment", "status": "success" }]}'import { Midwater } from "@midwater/sdk";const midwater = new Midwater(); // reads MIDWATER_API_KEY and MIDWATER_BASE_URLconst { id, status } = await midwater.conversations.create({external_id: "call_8f2a91",channel: "voice",ended_by: "caller",agent: { id: "front-desk", name: "Front desk", version: "1.0.0" },transcript: [{ speaker: "agent", text: "Thanks for calling, this call may be recorded. How can I help?" },{ speaker: "user", text: "I need to move my appointment to Thursday." },{ speaker: "agent", text: "Sure, I have Thursday at 10 AM. Does that work?" },{ speaker: "user", text: "Yes, that is perfect." },{ speaker: "agent", text: "Great, you are all set for Thursday at 10 AM." },],events: [{ type: "tool_call", name: "reschedule_appointment", status: "success" }],});from midwater import Midwaterclient = Midwater() # reads MIDWATER_API_KEY and MIDWATER_BASE_URLaccepted = client.conversations.create({"external_id": "call_8f2a91","channel": "voice","ended_by": "caller","agent": {"id": "front-desk", "name": "Front desk", "version": "1.0.0"},"transcript": [{"speaker": "agent", "text": "Thanks for calling, this call may be recorded. How can I help?"},{"speaker": "user", "text": "I need to move my appointment to Thursday."},{"speaker": "agent", "text": "Sure, I have Thursday at 10 AM. Does that work?"},{"speaker": "user", "text": "Yes, that is perfect."},{"speaker": "agent", "text": "Great, you are all set for Thursday at 10 AM."},],"events": [{"type": "tool_call", "name": "reschedule_appointment", "status": "success"}],})Midwater answers
202 Acceptedwith{ "id": "…", "status": "queued" }. The conversation is stored; scoring runs in the background. -
Read the result. Scoring usually takes a few seconds. Fetch the conversation by Midwater’s
idor by yourexternal_id:Terminal window curl "$MIDWATER_BASE_URL/v1/conversations/call_8f2a91" \-H "Authorization: Bearer $MIDWATER_API_KEY"const conversation = await midwater.conversations.wait(id); // polls until scoring finishesconsole.log(conversation.outcome);for (const r of conversation.results) console.log(r.check_name, r.verdict, r.reason);conversation = client.conversations.wait(accepted.id) # polls until scoring finishesprint(conversation.outcome)for r in conversation.results:print(r.check_name, r.verdict, r.reason)When
statusisdone, you get theoutcome(for exampleresolved) and one entry inresultsper check, each with its result, a likelihoodscore, how it was decided, and a one-sentencereason. Thedashboard_urlopens the conversation in the app.