React to events

Various actions done within a PubNub application result in generating a system-wide event of some kind. For example, you may receive an event each time a user joins a channel: “Emma has joined the room” or when a user updates their personal information: "Sam changed their profile picture."

Handling events connected to users subscribing to a channel or publishing a message is one thing, but you might also want to respond to certain PubNub API calls. For example, you may want to translate messages in flight, block profanity within the message body, send out data for sentiment analysis, or process GPS coordinates, just to name a few. You can, of course, do it on the client level, but if you want to quickly modify your custom logic, it's best to do it server-side.

PubNub's Events and Actions (E&A) feature allows you to react to all of the above by triggering custom business logic on the server without ever writing a single line of code.

There are two important elements involved in E&A:

  • Event listeners which wait for different PubNub events to occur and activate actions based on them.
  • Actions which are configurable ways of handling data when an event listener is activated.

To start working with E&A, head to the Admin Portal, select your keyset, and open the Events & Actions view. It is there that you create, configure, modify, and remove your event listeners and actions. Managing your event listeners and actions is entirely done using a graphical user interface, which makes it easier for non-technical people to configure additional business logic within an app.

Events and Actions User Interface

If you like getting your hands dirty while working with the code, you can create Functions using custom JavaScript code, which are executed when an event happens.

On this page