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 given user sends a message: “Emma has sent a new message."

Handling events connected to users 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 & Actions feature allows you to react to all of the above by triggering business logic on the server without ever writing a single line of code.

There are two important elements involved in Events & Actions:

  • 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 Events & Actions, head to the Admin Portal, select your keyset, and open the Events & Actions view. It's 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 & 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.

Last updated on
On this page