refactor chat delivery to graphql + hatchet services
This commit is contained in:
3
telegram_backend/src/hatchet/client.ts
Normal file
3
telegram_backend/src/hatchet/client.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { HatchetClient } from "@hatchet-dev/typescript-sdk/v1";
|
||||
|
||||
export const hatchet = HatchetClient.init();
|
||||
31
telegram_backend/src/hatchet/tasks.ts
Normal file
31
telegram_backend/src/hatchet/tasks.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { hatchet } from "./client";
|
||||
import type { OmniInboundEnvelopeV1 } from "../types";
|
||||
|
||||
export type TelegramOutboundTaskInput = {
|
||||
omniMessageId: string;
|
||||
chatId: string;
|
||||
text: string;
|
||||
businessConnectionId?: string | null;
|
||||
};
|
||||
|
||||
const processTelegramInbound = hatchet.task({
|
||||
name: "process-telegram-inbound",
|
||||
});
|
||||
|
||||
const processTelegramOutbound = hatchet.task({
|
||||
name: "process-telegram-outbound",
|
||||
});
|
||||
|
||||
export async function enqueueTelegramInboundTask(input: OmniInboundEnvelopeV1) {
|
||||
const run = await processTelegramInbound.runNoWait(input as any);
|
||||
return {
|
||||
runId: await run.runId,
|
||||
};
|
||||
}
|
||||
|
||||
export async function enqueueTelegramOutboundTask(input: TelegramOutboundTaskInput) {
|
||||
const run = await processTelegramOutbound.runNoWait(input as any);
|
||||
return {
|
||||
runId: await run.runId,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user