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 '@towns-protocol/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;
replyId?: string;
mentions?: PlainMessage<ChannelMessage.Post.Mention>[];
attachments?: PlainMessage<ChannelMessage.Post.Attachment>[];
} | undefined) => Promise<{
eventId: string;
}>;
}
Source: useSendMessage
Parameters
streamId
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;
replyId?: string;
mentions?: PlainMessage<ChannelMessage.Post.Mention>[];
attachments?: PlainMessage<ChannelMessage.Post.Attachment>[];
} | undefined) => Promise<{
eventId: string;
}>;
}