Events & Actions
Events & Actions is a no-code feature that watches activity inside PubNub. It forwards matching events to external systems, such as a webhook endpoint, a message queue, or a data lake. You configure it entirely in the Admin Portal, by creating event listeners that watch for specific PubNub events and actions that forward a matched event onward. No SDK code runs on your side to set this up.
How Events & Actions works
A client app publishes a message, connects, disconnects, or updates metadata, and PubNub generates an event from that activity. Each event listener on the keyset checks the event against its event source and optional filter. On a match, the listener runs the actions attached to it, up to your plan's limit. Each action then forwards the event data to its external system, such as a webhook endpoint or an Amazon SQS queue.
Events, listeners, and actions
An event is a small record PubNub generates from activity on your keyset. Some events are explicit, a direct result of an API call. Others are implicit. PubNub notices that something happened without your app making an API call.
| Scenario | PubNub event | Explicit or implicit |
|---|---|---|
| A device calls publish() on a channel | Message sent | Explicit. The API call directly produces the event. |
| A user's phone loses its Internet connection | User Disconnect, part of Presence | Implicit. PubNub detects the dropped connection without any API call. |
An event listener watches one event source for events, optionally narrowed by a filter, such as a specific channel or sender. When an event matches, the listener runs every action attached to it. A listener with no actions attached still runs on a match, but it has nothing to forward. See Event sources for every source and event type a listener can watch, and Available actions for every destination an action can forward to.
Events & Actions vs. Functions
Events & Actions and Functions both react to activity on your keyset, but they solve different problems.
- Use Events & Actions to forward event data to a third-party system with no code, when you need visibility into your data outside PubNub.
- Use Functions when you need to write JavaScript that transforms, validates, blocks, or reroutes a message, or that runs custom logic synchronously in the message path.
Availability by plan
PubNub Events & Actions limits by tier:
| Item | Free | Intro | Tier 1 | Tier 2 | Tier 3 | Tier 4 | Tier 5 | Tier 6 |
|---|---|---|---|---|---|---|---|---|
| Events ingested per month | 10K | 2M | 4M | 25M | 66M | 200M | 500M | Unlimited |
| Listeners | 1 | Unlimited | Unlimited | Unlimited | Unlimited | Unlimited | Unlimited | Unlimited |
| Actions per listener | 1 | 3 | 3 | 3 | 3 | 3 | Unlimited | Unlimited |
Your keyset's tier is set by your PubNub plan.
Events & Actions retries are available on paid tiers. The Free tier's single listener does not retry failed deliveries.
Every paid tier retries a failed delivery according to the retry policy you set on the action, described on Available actions.
For the dollar cost of each tier, see Pricing by feature. For the exact event, listener, and action allowances per tier, see Plan comparison.
Billing
Events & Actions bills by events ingested, not by the actions those events trigger. Every listener on your keyset evaluates every message published to it. Events & Actions calculates the billable count of ingested events by multiplying the messages published to a keyset by the number of active event listeners on that keyset, whether or not an event matches a filter or triggers an action. Each listener you add therefore raises the bill for all published traffic, so count listeners when you design your integration. See Pricing by feature and Plan comparison for the numbers.
Free trial
Events & Actions includes a two-week free trial. After the trial ends, contact sales to upgrade your plan.
Next steps
- Event sources. Look up every event type a listener can watch.
- Available actions. Look up every destination an action can forward to, and the retry, envelope, and batching rules they share.
- Events & Actions payloads. Look up the JSON payload for any event type.
- Configure Events & Actions. Create your first listener and attach an action to it in the Admin Portal.