{"id":271669,"date":"2025-07-23T07:14:00","date_gmt":"2025-07-23T07:14:00","guid":{"rendered":"https:\/\/www.revechat.com\/?post_type=help-center&#038;p=271669"},"modified":"2025-07-23T07:14:02","modified_gmt":"2025-07-23T07:14:02","slug":"event-listener","status":"publish","type":"help-center","link":"https:\/\/www.revechat.com\/help-center\/event-listener\/","title":{"rendered":"Event Listener"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p>You can add an event listener to listen for custom events triggered by the REVE Chat iframe. This allows you to handle specific actions or messages sent from the chat widget to your website.<\/p>\n\n\n\n<p>Use the following example to listen for a custom event from the REVE Chat iframe and handle the data.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Example<\/h4>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-javascript\">\/\/ Define a handler function for the custom event\nfunction handleCustomMessage(event) {\n  if (event.type === &#039;customRevechatMessage&#039;) {\n    const message = event.data;\n    console.log(&quot;Received message from iframe: &quot; + message);\n  }\n}\n\n\/\/ Add the event listener\ndocument.addEventListener(&#039;customRevechatMessage&#039;, handleCustomMessage);<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>Any questions? Please email us at <a href=\"mailto:support@revechat.com\">support@revechat.com<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can add an event listener to listen for custom events triggered by the REVE Chat iframe. This allows you to handle specific actions or messages sent from the chat widget to your website. Use the following example to listen for a custom event from the REVE Chat iframe and handle the data. Example Any [&hellip;]<\/p>\n","protected":false},"author":43,"featured_media":0,"menu_order":128,"template":"","meta":{"_acf_changed":false,"footnotes":""},"help_center_type":[1816],"class_list":["post-271669","help-center","type-help-center","status-publish","hentry","help_center_type-javascript-api"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.revechat.com\/wp-json\/wp\/v2\/help-center\/271669","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.revechat.com\/wp-json\/wp\/v2\/help-center"}],"about":[{"href":"https:\/\/www.revechat.com\/wp-json\/wp\/v2\/types\/help-center"}],"author":[{"embeddable":true,"href":"https:\/\/www.revechat.com\/wp-json\/wp\/v2\/users\/43"}],"version-history":[{"count":1,"href":"https:\/\/www.revechat.com\/wp-json\/wp\/v2\/help-center\/271669\/revisions"}],"predecessor-version":[{"id":271670,"href":"https:\/\/www.revechat.com\/wp-json\/wp\/v2\/help-center\/271669\/revisions\/271670"}],"wp:attachment":[{"href":"https:\/\/www.revechat.com\/wp-json\/wp\/v2\/media?parent=271669"}],"wp:term":[{"taxonomy":"help_center_type","embeddable":true,"href":"https:\/\/www.revechat.com\/wp-json\/wp\/v2\/help_center_type?post=271669"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}