Skip to main content
Besides the caller’s voice, your application can put words into a Prism conversation in three ways:
  • A typed turn stands in for speech. Prism treats the text as if the caller had said it and replies, so a caller can type a question instead of speaking it.
  • A nudge makes Prism speak when nobody has said anything, such as a greeting at pickup, a check-in after a long silence, or an update when a slow tool finally returns. You give it a one-off instruction for that reply.
  • History adds a line to the conversation without a reply, such as a greeting that your application already played. Prism builds its later replies on it.
The snippets build on Live conversations. They use the session that Open one session per call opens, and the events loop from Live conversations. That loop matters here: its playback reports tell Prism when a reply has finished playing, and typed turns and nudges wait for them. Over the WebSocket API, send typed turns and nudges as response.create after prism.typed_input.ready, and history as conversation.item.create.

Send text, nudges, and history

The SDK has one method for each kind of request: This sequence greets the caller, records a line that your application played, answers a typed question, and checks in. Run it on its own task beside the events loop, because the methods wait for playback that the loop reports:

Wait until Prism is idle

Prism does not start a typed turn or a nudge while anything else is happening. It is idle only when all three of these are true:
  • The caller is not speaking.
  • No reply is running or waiting.
  • The last reply has finished playing, or it made tool calls.
So send_text and request_reply do not fire at once. They wait until Prism is idle, and each returns when its reply starts. Two things can cut that short:
  • The wait runs out: each method waits for at most ready_s (readyS in Node.js), which is 30 seconds by default, and then raises RealtimeAdmissionTimeout. The session stays open.
  • The caller speaks first: live speech wins. Prism refuses the request, and the method raises RimeRealtimeError with one of the codes in Requested replies.
The text for send_text, request_reply, and add_message must not be blank, and it is at most 4,000 code points, as the limits list. Other text raises RimeInputError before the SDK sends anything. In the sequence above, the greeting starts right away, and add_message returns at once, because it asks for no reply. send_text then waits until the greeting has played and its playback report has gone out, and Prism answers “Today’s special is a cardamom bun.” from the line that you added. The check-in waits until that answer has played.

Next

Tools

Let Prism get data or take actions through functions that your backend runs. Then continue the reply with the result.