feat(widget): propagate client-side events through dispatched events#498
feat(widget): propagate client-side events through dispatched events#498simong wants to merge 4 commits intoelevenlabs:mainfrom
Conversation
This allows end-users to dispatch events to the widget which are then propagated to the back-end for handling. The following standard events are supported: - contextual updates - user activity - user message To prevent abuse, this is explicitly opt-in. The `allow-events` attribute needs to have a true value before the event listeners are bound. See https://elevenlabs.io/docs/agents-platform/customization/events/client-to-server-events
|
@kalvin807 @kraenhansen @PaulAsjes : I would love your feedback on this. We're building an integration which combines both MCP on the backend and some client-side logic to "nudge" the model on certain interactions. Having the ability to push client-side information to the LLM through the widget would be really helpful for us. |
|
@simong This is an awesome feature addition 🔥 thanks for the contribution. I’m considering making the three events individually configurable, which may require additional backend work to support opting out of client-side events (since attribute-based gating is easy to bypass). Would you mind if our team takes this over for now and follows up with you later? |
There was a problem hiding this comment.
Not sure if we want to duplicate the pattern from elevenlabs-agent:expand tbh
The reason it attaches a handler to both the document and the widget, and marks it via _convaiEventHandled, is because whoever implemented it initially listened for the event only on the document. Users then started complaining that this breaks when there are multiple widgets on the page. So I added a proper listener on the shadow host, but kept the document listeners and used a custom _convaiEventHandled instead of stopPropagation() for backwards compatibility
Here, since we are starting clean, I'd suggest we only listen on the host
|
Thank you both. No objections on my end on letting you move this forward. We'd happily beta test the feature if you need any volunteers :) |
* elevenlabs/main: fix(widget): send feedback when only a conversation id is available (elevenlabs#491)
This allows end-users to dispatch events to the widget which are then propagated to the back-end for handling.
The following standard events are supported:
See https://elevenlabs.io/docs/agents-platform/customization/events/client-to-server-events
To prevent abuse, this is explicitly opt-in. The
allow-eventsattribute needs to have a true value before the event listeners are bound.This follows the same pattern as the
:expandedevent:packages/packages/convai-widget-core/src/widget/Wrapper.tsx
Lines 81 to 106 in 4dac770