---
source_url: https://www.pubnub.com/docs/chat/sdks/users/mentions
title: Mentioning users (deprecated)
updated_at: 2026-06-30T11:05:03.380Z
---

> Documentation Index
> For a curated overview of PubNub documentation, see: https://www.pubnub.com/docs/llms.txt
> For the full list of all documentation pages, see: https://www.pubnub.com/docs/llms-full.txt


# Mentioning users (deprecated)

:::warning Use Chat SDKs
This documentation is deprecated. Use any of our dedicated [Chat SDKs](https://www.pubnub.com/docs/chat/overview) to quickly implement chat functionality in your application.
:::

Mentions enable users to get notified when their `@username` is mentioned in a chat room. You can build logic on the client to directly parse messages and trigger these notifications to user channels. Or, if you prefer to keep your user channels secure, you can use Functions to parse messages and publish these notifications.

[PubNub's User Mentions Function](https://www.pubnub.com/integrations/use-mention-notify/) parses all messages that travel through the chat channels. If `@username` is detected, the same message is forwarded to the `@username` channel. The original message still reaches the intended target. Every user should have their own `@username` channel, locked down with Access Manager such that only they can access it.

## Set up the PubNub Function

To add the PubNub Function, do the following:

1. Create a new function. Go to your Admin Portal and create a new module, and then create a new After Publish function. The function should be set up to trigger on a specific set of channels (such as chat.*) or on all channels using wildcards (*).
2. Copy the function code. Copy the code that checks the contents of each message for @username mentions and publishes those messages to the @username channel. You can add custom logic to the function to find the appropriate user channels to forward messages. 1export default (request) => {2 var console = require('console');3 var pubnub = require('pubnub');4 5 try {6 var message = request.message;7 var pattern = /\B@[a-z0-9_-]+/gi;8 var usernames = message.match(pattern);9 10 // for every username found, forward the message to a channel11 // with the same name (ex: "@username")12 usernames.forEach(function(username) {13 pubnub.publish({14 channel: username,15 message: message16 });17 });18 19 return request.ok();20 21 } catch (e) {22 // This is the place for exception handling.23 // Be sure to make best use of this ;)24 console.error('Uncaught exception:', e);25 }26};
3. Start the function. Click Start module to start the function, and test it using the Publish button and Test Payload field on the left.

For more information on creating functions, refer to [Create a Function](https://www.pubnub.com/docs/serverless/functions/run#create-a-function).

## Test the Function

**Input**: A message is published on the input channel.

```text
"A message that mentions a @username"
```

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

```text
"A message that mentions a @username"
```