Building your application
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 class. Here is an example of how you can listen to incoming messages and reply/react to them:
Exposed Events
The SDK supports the following events out of the box to make it easy to handle both the user and system events:
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
- Image Message Event
- Video Message Event
- Audio Message Event
- Document Message Event
- Location Message Event
- Contact Message Event
- Reaction Message Event
- Sticker Event
- Quick Reply Button Interaction Event
- Ad Interaction Event
- Product Inquiry Event
- Reply Button Interaction Event
- List Interaction Event
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
- Message Read Event
- Message Sent Event
- Message Failed Event
- Message Undelivered Event
- Customer Identity Changed Event
- Customer Number Changed Event
Was this page helpful?