{.section-title.accent.text-primary} # API Room functions Reference ### Detecting when the user enters/leaves a zone ``` WA.room.onEnterZone(name: string, callback: () => void): void WA.room.onLeaveZone(name: string, callback: () => void): void ``` Listens to the position of the current user. The event is triggered when the user enters or leaves a given zone. The name of the zone is stored in the map, on a dedicated layer with the `zone` property.
The `zone` property, applied on a layer
* **name**: the name of the zone, as defined in the `zone` property. * **callback**: the function that will be called when a user enters or leaves the zone. Example: ```javascript WA.room.onEnterZone('myZone', () => { WA.chat.sendChatMessage("Hello!", 'Mr Robot'); }) WA.room.onLeaveZone('myZone', () => { WA.chat.sendChatMessage("Goodbye!", 'Mr Robot'); }) ```