//native
type Clickup = {
token: string;
};
/**
* Send a message
* This endpoint creates a top level message.
*/
export async function main(
auth: Clickup,
workspace_id: string,
channel_id: string,
body: {
assignee?: string;
group_assignee?: string;
triaged_action?: 1 | 2;
triaged_object_id?: string;
triaged_object_type?: number;
type: "message" | "post";
content: string;
reactions?: { date: number; reaction: string; user_id: string }[];
followers?: string[];
content_format?: "text/md" | "text/plain";
post_data?: { title: string; subtype: { id: string } };
},
) {
const url = new URL(
`https://api.clickup.com/api/v3/workspaces/${workspace_id}/chat/channels/${channel_id}/messages`,
);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago