Develop serverless edge functions with PubNub Functions 2.0
Agent Success
Agent success rate when using this tile
93%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.79x
Baseline
Agent success rate without this tile
52%
You are building a PubNub Function that runs when messages are published to any chat channel. The function should look up the sender's profile from the key-value store and attach their display name and avatar URL to the message before it reaches subscribers. It should also add a server-side timestamp. If the user profile is not found, the message should still go through with default values.
Write a PubNub Before Publish function (enrich-message.js) that:
enrich-message.js file containing a complete PubNub Function ready for deployment.