> ## Documentation Index
> Fetch the complete documentation index at: https://javascript.wapikit.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Handle Events

> Learn how to handle events using the Wapi.js SDK

Wapi.js SDK implements Node.js native EventEmitter class to implment event handling.

## Listen to Events:

You can listen to events using the `on` method available on the [client](api-reference/classes/Client) class. Here is an example of how you can listen to incoming messages and reply/react to them:

```typescript theme={null}
// assuming you have already initiated the client,


whatsappClient.on('Ready', async () => {
        console.log("Client is ready to receive messages.")
})

whatsappClient.on('Error', async error => {
        console.errpr("An error occured.", error)
})

whatsappClient.on('TextMessage', async message => {
        await message.reply({
            message: new TextMessage({
                text: 'This is a reply.'
            })
        })
})

whatsappClient.on('AudioMessage', async message => {
        await message.reply({
            message: new TextMessage({
                text: 'This is a reply.'
            })
        })
})

// and so on for other message types...

```

## Exposed Events

The SDK supports the following events out of the box to make it easy to handle both the user and system events:

> [!NOTE]
>
> There is no messaging or system event handling differences in the SDK, here they are just bifurcated for the educational puposes.

### Messaging Events:

* [Text Message Event](https://javascript.wapikit.com/api-reference/classes/TextMessageEvent.md)
* [Image Message Event](https://javascript.wapikit.com/api-reference/classes/ImageMessageEvent.md)
* [Video Message Event](https://javascript.wapikit.com/api-reference/classes/VideoMessageEvent.md)
* [Audio Message Event](https://javascript.wapikit.com/api-reference/classes/AudioMessageEvent.md)
* [Document Message Event](https://javascript.wapikit.com/api-reference/classes/DocumentMessageEvent.md)
* [Location Message Event](https://javascript.wapikit.com/api-reference/classes/LocationMessageEvent.md)
* [Contact Message Event](https://javascript.wapikit.com/api-reference/classes/ContactMessageEvent.md)
* [Reaction Message Event](https://javascript.wapikit.com/api-reference/classes/ReactionMessageEvent)
* [Sticker Event](https://javascript.wapikit.com/api-reference/classes/StickerMessageEvent.md)
* [Quick Reply Button Interaction Event](api-reference/interfaces/QuickReplyButtonInteractionEvent)
* [Ad Interaction Event](https://javascript.wapikit.com/api-reference/classes/AdInteractionEvent.md)
* [Product Inquiry Event](https://javascript.wapikit.com/api-reference/classes/ProductInquiryEvent.md)
* [Reply Button Interaction Event](https://javascript.wapikit.com/api-reference/classes/ReplyButtonInteractionEvent.md)
* [List Interaction Event](https://javascript.wapikit.com/api-reference/classes/ListInteractionEvent.md)

> [card] Important
>
> Each of the events mentioned above has a couple of utility methods available like `reply`, `react` etc. which can be used to reply or react to the incoming messages.

### System Events

* Client Ready Event
* Client Error Event
* [Message Delivered Event](https://javascript.wapikit.com/api-reference/classes/MessageDeliveredEvent)
* [Message Read Event](https://javascript.wapikit.com/api-reference/classes/MessageReadEvent.md)
* [Message Sent Event](https://javascript.wapikit.com/api-reference/classes/MessageSentEvent.md)
* [Message Failed Event](https://javascript.wapikit.com/api-reference/classes/MessageReceivedEvent)
* [Message Undelivered Event](https://javascript.wapikit.com/api-reference/classes/MessageUndeliveredEvent.md)
* [Customer Identity Changed Event](https://javascript.wapikit.com/api-reference/classes/CustomerIdentityChangedEvent)
* [Customer Number Changed Event](https://javascript.wapikit.com/api-reference/classes/CustomerNumberChangedEvent)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.