Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

842 B
Raw Blame
import type { ChatTopicBotContext } from '@lobechat/types';

import type { NotificationWebhook } from '@/server/services/agentRuntime/hooks/types';

const BOT_CALLBACK_URL = '/api/agent/webhooks/bot-callback';

export interface CreateBotCompletionHookParams {
  body?: Record<string, unknown>;
  botContext: ChatTopicBotContext;
  userId: string;
  workspaceId?: string;
}

export const createBotCompletionWebhook = ({
  botContext,
  body,
  userId,
  workspaceId,
}: CreateBotCompletionHookParams): NotificationWebhook => ({
  body: {
    applicationId: botContext.applicationId,
    messengerInstallationKey: botContext.messengerInstallationKey,
    platformThreadId: botContext.platformThreadId,
    type: 'completion',
    userId,
    workspaceId,
    ...body,
  },
  delivery: 'qstash',
  fallback: 'none',
  url: BOT_CALLBACK_URL,
});