Skip to main content
Layercode supports more than voice or text replies. When you need to pass button clicks, form submissions, or other UI state to your agent backend mid-turn, emit a client.response.data event from the client SDK. The payload arrives at your webhook as a data event without interrupting the current turn. The webhook can respond with a regular JSON response (not an SEE stream like other webhook event types), which is then delivered immediately back to the client as a response.data event. This data flow is in addition to the ability of other webhook event types (like message or session.start) returning response.data SEE events, which are also sent to the client as response.data events.

Vanilla JS example

send-data.html
What happens:
  • The current turn continues uninterrupted.
  • The payload is forwarded as a data webhook event with the session/turn identifiers.

React example

app/components/OrderActions.tsx

Backend example

When the client emits client.response.data, your webhook receives a data event. Respond with plain JSON (not SSE messages) using type: "response.data". The payload is delivered to the client and surfaced via the onDataMessage callback. The snippet below only handles the data event for clarity:
Express
On the client, read this via onDataMessage (the same applies to the React SDK):