Proactive action on chat icon click!

Hi how would I go about sending a proactive action event when the user clicks the chat icon?

I’ve tried on click on the iframe but it doesn’t work.

I found a way to do it but I don’t really like how it works (I would prefer to listen to an event that tell Botpress finished its init so I can just put a click listener on the button).

Anyway my solution is to listen for MessageEvent and when there is bp-widget-side in this means the chat is open so I can send a proactive event.

Here is my code in my index.html :

			host: 'http://localhost:3000',
			botId: 'my-bot',
			extraStylesheet: "/assets/css/custom-style.css"

		window.addEventListener('message', message => {
			if( &&'bp-widget-side')) {
									type: 'proactive-trigger',
									channel: 'web',
									payload: {
										text: 'fake message'


My before_incoming_middleware hook to catch the event is the same as in the docs.

1 Like

Hi @thenilaymodi @vgalisson,

The webchat structure has changed a bit recently. Please see the revised documentation in this PR. It will be merged soon.

Thanks for the feedback!

1 Like