Docs
/
In-App UI
React
Hooks
useConnectedSlackChannels

useConnectedSlackChannels

The useConnectedSlackChannels hook is used to retrieve and manage Slack channels that are currently connected for a specific recipient object. This hook must be used within a KnockSlackProvider.

Parameters

#

Accepts an object with the following properties:

slackChannelsRecipientObjectRecipientObjectRequired

The recipient object (with objectId and collection) to get connected channels for.

Returns

#

Returns an object with the following properties:

dataSlackChannelConnection[] | null

Array of connected Slack channels for the recipient object.

updateConnectedChannels(channels: SlackChannelConnection[]) => Promise<void>

Function to update the connected channels for the recipient object.

loadingboolean

Whether connected channels are being loaded or revalidating.

errorstring | null

Error message if the request failed.

updatingboolean

Whether an update operation is in progress.

Example

#

Basic usage

#

The following example demonstrates how to use the useConnectedSlackChannels hook to display and manage connected Slack channels.

Updating connected channels

#

You can add or update connected channels by calling updateConnectedChannels with the new array: