At some point in your development, you will almost certainly want to do something with your messages in between points A and B. It may be transforming a message’s content, setting up if/then rules to govern routing behavior, or filtering for messages that meet certain criteria. It’s also likely you do not want to deploy and scale your own servers to run this business logic, nor incur the added latency of an additional hop outside of the PubNub network.
PubNub Functions run in a secure environment, controlled completely by the developer. PubNub Functions can only operate on data made visible to them. If messages are encrypted, there is no way for a module to execute business logic on the encrypted payload, as encryption keys never leave the client side. However, you can include information in the message envelope header for PubNub Functions to see, residing outside of the encrypted message body. This same information provided in the header can be used for Stream Filter.
You can create modules via the GUI of your Admin Dashboard, or through a command line tool.
For further learning, please see: