React to events
Various actions in a PubNub app generate system‑wide events. For example, you may receive an event each time a user sends a message: “Emma has sent a new message.”
Handling message events is one case. You might also respond to PubNub API calls. Examples include translating messages in flight, blocking profanity, sending data for sentiment analysis, or processing GPS coordinates. You can do this in the client. To modify logic quickly and centrally, use server‑side handling.
Events & Actions lets you react to these events by triggering server‑side business logic without writing code.
Events & Actions includes two parts:
- Event listeners wait for PubNub events and trigger actions.
- Actions define how to handle data when an event listener fires.
To start, go to the Admin Portal, select your keyset, and open the Events & Actions view. There you create, configure, modify, and remove event listeners and actions. You can manage them in a graphical interface, which makes setup quick and easy.
You can also create Functions with custom JavaScript that run when events occur.