User @mention Notification

Forward @username mentions to another channel

Ever get pinged because your @username was mentioned in a chat room? This Function will get you started with that same flow. It parses all messages that travel through the channel. If that message has a @username mention in it, it forwards the message to the @username channel.

Setup

  1. Login or Register to Admin Portal

  2. Select Functions

  3. Select your desired App and Keyset

  4. Select "Explore Templates" and proceed with selected integration.

Walkthrough

Any message sent over your channel will be parsed for the @username using a regular expression. If @username is detected, the same message is forwarded to the @username channel. The original message still reaches the intended target.

In production every user should have their own @username channel that is locked down with PubNub PAM so only they can access it.

Input

A message is published on the input channel: user-mention-channel

1

Output

Note that the message is identical, but the new message has been duplicated and sent to a channel called @username.

1

Talk to an expert