# Scheduling widget events

**URL:** <https://community.hubspot.com/t/scheduling-widget-events/80523>\
**Category:** APIs & Integrations\
**Tags:** developer-tools\
**Created:** [May 3, 2023, 7:33pm UTC](https://community.hubspot.com/t/scheduling-widget-events/80523 "2023-05-03T19:33:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![RDDemo](https://avatars.discourse-cdn.com/v4/letter/r/5fc32e/32.png) [@RDDemo](https://community.hubspot.com/u/RDDemo)\
**Post date:** [May 3, 2023, 7:33pm UTC](https://community.hubspot.com/t/scheduling-widget-events/80523/1 "2023-05-03T19:33:20Z")

</div>

Hey,

I’m integrating the Scheduling widget on my page and I would like to get javascript MessageEvent’s from the user interaction on the widget like some Hubspot competitor’s do.

Is this something that the widget does? (couldn’t find in the documentation)

Thanks for the help.

---

<div class="post-metadata">

**Author:** ![himanshurauthan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/himanshurauthan/32/53076_2.png) [@himanshurauthan](https://community.hubspot.com/u/himanshurauthan)\
**Post date:** [May 4, 2023, 10:20am UTC](https://community.hubspot.com/t/scheduling-widget-events/80523/2 "2023-05-04T10:20:25Z")

</div>

Hello @RDDemo

The scheduling widget typically allows users to book appointments or meetings with you by selecting a time and date that works for them. However, it does not natively generate JavaScript Message Events based on user interactions with the widget.

That being said, if you are using a third-party scheduling widget that provides an API, you may be able to use that API to achieve the desired functionality. Depending on the specific widget you are using, you may be able to listen for specific events, such as when a user selects a time slot, and then trigger the appropriate actions using JavaScript.

If the scheduling widget you are using does not offer an API or does not provide the functionality you are looking for, you may need to consider other options, such as building a custom scheduling solution that provides the necessary functionality.

---

<div class="post-metadata">

**Author:** ![GRajput](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/grajput/32/102020_2.png) [@GRajput](https://community.hubspot.com/u/GRajput)\
**Post date:** [May 10, 2023, 3:49pm UTC](https://community.hubspot.com/t/scheduling-widget-events/80523/3 "2023-05-10T15:49:01Z")

</div>

Hi @RDDemo

Yes, it is possible to capture JavaScript `MessageEvent` from the HubSpot Scheduling widget. The HubSpot Scheduling widget supports messaging through the `window.postMessage()` method, which allows you to send messages between the parent window and the iframe containing the widget.

To capture the message event, you can listen for it in your parent window using the `window.addEventListener()` method. Here’s an example:

```  
// Listen for the message event  
window.addEventListener(‘message’, function(event) {  
// Check if the message is from the scheduling widget  
if (event.origin === ‘[https://app.hubspot.com](https://app.hubspot.com)’) {  
// Get the message data  
var messageData = event.data;  
// Do something with the message data  
console.log(‘Received message:’, messageData);  
}  
});  
```

In this example, the `window.addEventListener()` method listens for the message event and checks that it is coming from the HubSpot app domain. Once the message data is received, you can perform any necessary actions based on the data.

Note that the message data format is specific to the HubSpot Scheduling widget, so you will need to refer to the widget documentation to understand the data format and message types that are available.

Hope this helps you out. If you find it helpful, please mark it as solution.

Thanks!

---

<div class="post-metadata">

**Author:** ![alettieri](https://avatars.discourse-cdn.com/v4/letter/a/b5ac83/32.png) [@alettieri](https://community.hubspot.com/u/alettieri)\
**Post date:** [October 11, 2023, 6:48pm UTC](https://community.hubspot.com/t/scheduling-widget-events/80523/4 "2023-10-11T18:48:22Z")

</div>

We are using a similar approach for this. The only concern I have is around the interface of the message body. I’d like to be ensured that the body won’t change drastically, so am wondering if there’s a documented location on what the interface of the post message from the frame will look like?

---

<div class="post-metadata">

**Author:** ![alettieri](https://avatars.discourse-cdn.com/v4/letter/a/b5ac83/32.png) [@alettieri](https://community.hubspot.com/u/alettieri)\
**Post date:** [October 12, 2023, 4:45pm UTC](https://community.hubspot.com/t/scheduling-widget-events/80523/5 "2023-10-12T16:45:16Z")

</div>

I just wrote a component and in our next-js application. Perhaps it could be a good point of reference for other folks: [HubSpot React/Next Scheduler Widget Component · GitHub](https://gist.github.com/alettieri/f382458694b8c73a321f3ccad36f69f2)
