Skip to main content
A camera session is a voice session plus images. The browser sends still JPEG images from the webcam on the same WebSocket as the audio. The agent hears the user and sees what is in front of the camera. This page covers only the camera parts. The audio side is the same as a voice session. See Voice in the browser first.

What it is good for

  • Visual troubleshooting. The user shows the broken thing and describes the problem.
  • Guided physical tasks. Assembly, installation or setup, with the user’s hands free.
  • Reading documents. The user holds up a card, a label or a form.
  • Anything that is easier to show than to describe.
The agent sees up to one still image per second. It is not a video call. The agent cannot follow motion or gestures. See What the agent can see.

Turn the camera on or off

Camera sessions are on by default for every agent. The setting is enable_webcam. It is the same setting the dashboard and the embed widget use.
PATCH only changes the flags you send. All other settings stay the same. When the camera is off, creating a camera session fails with 403:
If someone turns the camera off after the session was created but before it connected, the socket closes with code 4003. Handle both.

Build a camera page

1

Create a camera session on your server

Use the token endpoint from Voice in the browser. The library adds ?source=camera to the request, and the endpoint passes it on. If you write your own endpoint, set source to camera:
token-endpoint.mjs
2

Start the session with a video element

Pass source: "camera" and a <video> element for the preview:
Here is a complete page:
camera.html
The preview is mirrored with CSS, as users expect. The images sent to the agent are not mirrored, so text the user holds up stays readable.

Image settings

Set these on the EclatiraSession constructor. The defaults work well for most cameras.

The agent needs the microphone too

A camera session with no audio never gets a reply. The agent only takes a turn when it hears speech. Images alone do not start a turn. The session connects, accepts every image, and waits forever.
When images keep arriving with no audio, the server sends this once, after about 8 seconds:
The session stays open. Show this error in your UI. Two things cause it:
  1. No audio track. You called getUserMedia({ video: true }) without audio: true.
  2. Audio at the wrong sample rate. The audio arrives, so no_audio_received does not fire. But the agent cannot understand it. See Media format. The library fixes this for you.
To make the agent comment on an image without the user speaking, send text. The agent replies right away:

Handle camera problems

Permission denied

getUserMedia throws an error when it fails. The library asks for the camera before it creates the session, so a denied camera does not use up a session. Show a clear message for each case:
  • The camera only works on https:// pages and http://localhost. Testing from a phone against your laptop’s IP address over http:// fails.
  • Ask for the camera and the microphone in one call. If you ask separately and only the microphone fails, you get a video-only session that never replies.

The camera stops during the session

A camera can stop on its own. The user unplugs it, another app takes it, or the system revokes access. The socket stays open, but images stop. Listen for it:

End the session cleanly

session.stop() stops the image timer, closes the socket, stops every track and releases the preview. The camera light turns off. If you build without the library, stop every track. Closing the socket is not enough. The camera light stays on until each track is stopped:

What the agent can see

The agent gets up to one new still image per second. Each image stands alone. Write your agent’s instructions with this in mind.

Works well

  • Reading text, labels, serial numbers and handwriting held still
  • Identifying objects, parts, damage and colors
  • Checking that a step is done (“hold it up so I can see”)
  • Counting a few objects that are not moving

Does not work

  • Following motion, gestures or sign language
  • Anything that changes faster than once a second
  • Reading moving or blurry objects
  • Reading small text far from the camera
The server tells the agent that the user has shared their camera. It does not tell the agent how often images arrive. Add that to the agent’s instructions:
Agent instruction

Limits

  • Images are not stored. You cannot read them back later.
  • The session type is fixed. You cannot turn on the camera during an audio session. Start a new camera session instead. The conversation does not carry over.
  • Build without the library? Media format has the full image pipeline.

Next steps

Screen share

The same idea, for the user’s screen.

Troubleshooting

The agent connects but never speaks.