Files
automatisch/packages/backend/src/apps/slack/actions/send-a-message-to-channel/post-message.ts
2022-10-22 19:50:25 +02:00

27 lines
488 B
TypeScript

import { IGlobalVariable } from '@automatisch/types';
const postMessage = async (
$: IGlobalVariable,
channelId: string,
text: string
) => {
const params = {
channel: channelId,
text,
};
const response = await $.http.post('/chat.postMessage', params);
if (response.data.ok === false) {
throw new Error(JSON.stringify(response.data));
}
const message = {
raw: response?.data?.message,
};
$.setActionItem(message);
};
export default postMessage;