Skip to content

Programmatically open or close the Copilot widget #1638

@francisjervis

Description

@francisjervis

Is your feature request related to a problem? Please describe.
Use case is displaying the copilot with eg a user satisfaction survey when the page loads/after a preset delay. This is not currently possible (or at least, is not documented and is not obvious from inspecting the source code).

Describe the solution you'd like
Adding "show_copilot" and "hide_copilot" class methods (or similar) to enable the copilot to be shown/hidden from JS loaded on the page.

Describe alternatives you've considered
1: Sending click events to the relevant elements to simulate user interaction. Hack-y and potentially unstable if changes are made to the copilot code (eg in widget.tsx) which change the id of the relevant elements (these should not be breaking changes).
2: Examining the widget.tsx code for events related to setIsOpen which can be piggybacked off to deliver this functionality (unsuccessfully).

Additional context
Additional functionality such as a "with_first_message" optional param (enabling a conversation to be started programmatically with a "starter" message, eg if a user clicks a button) and/or passing a dictionary of key-value pairs to the server would broaden the use cases for this feature.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions