Ask a Question
Back to All

Advanced chat customization events not triggering

I'm following the instructions in the Gorgias documentation to customize a chat widget using the Gorgias customization API. My intention is to programmatically open a chat widget and then run some custom code after it has been opened.

According to the documentation, the widget:opened event should fire anytime the widget is opened. Unfortunately, it appears that programmatically opening the widget using GorgiasChat.open() does not fire this event. I am able to observe that the widget:opened event is properly firing if I manually click the Gorgias button.

So how can I go about running code on my widget when the Gorgias Chat window opens programmatically? I need to run custom CSS on the widget itself, so need a way of programmatically knowing when it opens so I can run the javascript code to do so.

GorgiasChat.init().then(function() {
    GorgiasChat.on('widget:opened', function() {
        // this only fires when manually opening the widget, and is not firing when programmatically opening it like below
        console.log("widget opened");