Skip to main content
TelzinoChat lets a visitor chat with an agent by text. The agent answers with the same setup that answers its text messages: its prompt, tools and model. Chat uses the same publishable key as voice, so the page’s origin must be on the key’s allowed origins.

Plain JavaScript

send() resolves once Telzino has accepted the message. The visitor’s own message and the agent’s reply both arrive as message events, in order. Call chat.close() when the chat widget goes away.

Options

Returning visitors

The visitor id is stored in localStorage per agent, so a visitor who comes back continues the same conversation. load() fetches the latest 100 messages. If the browser blocks storage, each page load starts a new conversation.

React

Inside <TelzinoProvider>, useChat gives you the thread and a send function.
useChat(agentId, { visitorId }) accepts the same visitorId option. It needs a publishableKey on the provider; a provider configured only with a session function reports an invalid_request error.

How replies arrive

After a message is sent, the SDK asks Telzino for new messages about once a second until the reply is in, for at most 90 seconds. After a failed request it waits longer each time, up to 15 seconds. Replies usually take 2 to 10 seconds, depending on the agent’s model and tools.

Errors

Errors are TelzinoErrors with a code: See Send Chat Message for the HTTP API and its limits.