•8 months ago
Not all chat apps are the same. Some may need interactions other than the regular sending of messages, reactions, typing indicators, etc. Delivery apps, for example, may require a "delivery completed" event. Dating apps, a "match" event. That is why you must use an underlying chat technology that is flexible enough and lets you build custom interactions. Stream Chat is heavily customizable to fit the requirements that make your app unique.
By default, when sending a custom event, a user must either be a member or a watcher of the channel. When the event is dispatched, all users watching the channel will receive it. Custom events are enabled by default in all channel types. You can change these permissions in the dashboard or via the API.
Make sure to validate your custom events properly via their types and additional fields since malicious users could try to take advantage of them.
Send Custom Event
To send a custom event, you should call the
channel.sendEvent method with a type and any additional field you may need.
Send From Server
To send a custom event from the server, you call the same method (
channel.sendEvent), but you also need to include a
We're excited to bring yet another feature to help your app stand out from the rest. For more information about this new feature, see the documentation on custom events. If you need help or have specific feedback about this feature, please leave a comment on the documentation page.