{.section-title.accent.text-primary} # API Reference ### Sending a message in the chat ``` sendChatMessage(message: string, author: string): void ``` Sends a message in the chat. The message is only visible in the browser of the current user. * **message**: the message to be displayed in the chat * **author**: the name displayed for the author of the message. It does not have to be a real user. Example: ```javascript WA.sendChatMessage('Hello world', 'Mr Robot'); ``` ### Listening to messages from the chat ```javascript onChatMessage(callback: (message: string) => void): void ``` Listens to messages typed by the current user and calls the callback. Messages from other users in the chat cannot be listened to. * **callback**: the function that will be called when a message is received. It contains the message typed by the user. Example: ```javascript WA.onChatMessage((message => { console.log('The user typed a message', message); })); ``` ### Detecting when the user enters/leaves a zone ``` onEnterZone(name: string, callback: () => void): void 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.