Send botpress event on chat start

Hi. Apologies if this is the wrong sub, I’m new here :slight_smile:

I’m using hlatki01/botpress-connector to connect RocketChat to my botpress bot. It’s working fine. However, visitors have to type something into the livechat widget to trigger an initial bot response. I’d prefer the bot agent to start the conversation as soon as the widget is opened. The botpress docs say the way to do this is by sending a botpress event from the page:

window.botpressWebChat.sendEvent({
  type: "proactive-trigger",
  channel: "web",
  payload: {
    text: "fake message",
  },
})

… and catching the event in a botpress before_incoming_middleware hook.

However, I’m not embedding botpress on the page - I don’t have window.botpressWebChat. I’m a bit stuck - how can I trigger some sort of event when the livechat widget is opened, so that the botpress agent receives it and can greet the visitor?