Realtime Triggers
Realtime Triggers allow you to execute logic every time a message is sent to a realtime channel
Last updated
Realtime Triggers allow you to execute logic every time a message is sent to a realtime channel
Last updated
Realtime Triggers are a key piece of our realtime functionality. They allow you to execute a function stack for events and messages sent to your realtime channels. This is vital in scenarios such as message filtering, logging, or anything else you want to have happen to the data sent through your channels.
Triggers are not required to utilize realtime, but it is important to be familiar with them as most use cases will likely take advantage of them.
After you have enabled realtime and set up a channel. you'll see an option to add triggers to that channel in the same panel. Click on Manage Triggers and then Add Realtime Channel Trigger.
Name
Give your trigger a name
Description
(Optional) Give a description to your trigger
Active
Enables or disables the trigger
Add Tag
Add tags to your triggers
Actions
Message - Execute this trigger when a message is sent to the channel
Join - Execute this trigger when someone joins the channel
Set up your trigger with your preferred options as described above, and click Save. You will be immediately taken to the function stack so you can start building your realtime trigger!
Action and Command
This will be either 'join' or 'message' depending on what was responsible for executing the trigger.
Action and Command currently have the same values, but behind the scenes, the values do not come from the same source. We maintain two separate inputs for the purpose of expanding this functionality in the future.
Channel
The channel that this command or message is being sent to
commandOptions
Any options that are provided with the command being sent to the channel
payload
The contents of the command, such as the message body
client
An internal client ID
Your response will by default just return the message or command exactly as the realtime channel would expect it. You can modify this response to whatever you wish. It is important in a majority of use cases, however, to ensure that the message is returned as self to maintain your frontend's ability to process messages.