Hook to send a message to a stream. Can be used to send a message to a channel or a dm/group dm.

Imports

import { useSendMessage } from '@river-build/react-sdk'

Definition

function useSendMessage(
  streamId: string,
  config?: ActionConfig<Channel['sendMessage']>,
): {
    data: {
        eventId: string;
    } | undefined;
    error: Error | undefined;
    isPending: boolean;
    isSuccess: boolean;
    isError: boolean;
    sendMessage: (message: string, options?: {
        threadId?: string | undefined;
        replyId?: string | undefined;
        mentions?: PlainMessage<ChannelMessage.Post.Mention>[] | undefined;
        attachments?: PlainMessage<ChannelMessage.Post.Attachment>[] | undefined;
    } | undefined) => Promise<{
        eventId: string;
    }>;
}

Source: useSendMessage

Parameters

streamId

  • Type: string

The id of the stream to send the message to.

config

  • Type: ActionConfig<Channel['sendMessage']>
  • Optional

Configuration options for the action.

Return Type

The sendMessage action and the status of the action.

{
    data: {
        eventId: string;
    } | undefined;
    error: Error | undefined;
    isPending: boolean;
    isSuccess: boolean;
    isError: boolean;
    sendMessage: (message: string, options?: {
        threadId?: string | undefined;
        replyId?: string | undefined;
        mentions?: PlainMessage<ChannelMessage.Post.Mention>[] | undefined;
        attachments?: PlainMessage<ChannelMessage.Post.Attachment>[] | undefined;
    } | undefined) => Promise<{
        eventId: string;
    }>;
}