Skip to content

[Widget] Add auto-start-text attribute for server-driven opening messages - #1011

Draft
teotoplak wants to merge 1 commit into
mainfrom
teo/widget-auto-start-text
Draft

teotoplak wants to merge 1 commit into
mainfrom
teo/widget-auto-start-text

Conversation

@teotoplak

Copy link
Copy Markdown
Contributor

Motivation

PostNord (Slack thread) wants the agent to greet widget users with a personalized, server-generated first message: the client passes only a customer_hash_id dynamic variable, a workflow tool resolves it to customer context, and the agent greets with that context.

The backend already supports this: a workflow whose start path leads to a tool node forces the first agent turn on connect (RuntimeStartAgent), and entry_behavior: generate_immediately does the same for agent-node entries. Mobile/JS SDK users get this today because they control when the session starts.

The embed widget is the one place it cannot work: in text mode the widget renders the configured first message locally and only opens the connection when the user sends their first message, so the agent never gets a chance to speak first.

What this does

Adds an opt-in auto-start-text attribute:

<elevenlabs-convai
  agent-id="..."
  auto-start-text="true"
  dynamic-variables='{"customer_hash_id": "abc123xyz"}'>
</elevenlabs-convai>

When set, the widget starts a text-only session as soon as the chat panel opens (immediately with default-expanded), and the opening message arrives over the wire from the agent. Scoped to text sessions on purpose: auto-starting voice would trigger a mic permission prompt on open.

Behavior notes:

  • Starts at most once per widget mount; a session the user ended does not restart on its own.
  • No-op when the agent does not support text or the attribute is absent, and terms acceptance still gates the start.
  • Session start goes through the existing startSession path, so the elevenlabs-convai:call event still fires and can be used to inject fresh config.

Testing

  • New browser tests: session auto-starts on open and renders the server-sent greeting; without the attribute nothing connects.
  • Full convai-widget-core suite passes except DismissButton.test.ts ("expandable widget should hide all elements when dismissed"), which fails identically on clean main.

Screenshot from the browser test (MSW-mocked backend): the panel just opened, no user input, and the server-sent greeting is rendered. Real-agent capture pending an agent configured with a start-to-tool workflow.

Follow-ups

  • Document the attribute in elevenlabs/docs.
  • Optionally expose this as a dashboard widget setting so it can be enabled without touching the embed snippet.

🤖 Generated with Claude Code

…ages

When set, the widget starts a text conversation as soon as the chat panel
opens instead of waiting for the user's first message. This lets the agent
generate the greeting server-side, e.g. from a workflow that resolves
customer context through tools before speaking.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant