UNPKG

@forgeflowai/chat

Version:

This is an embeddable Chat widget for n8n. It allows the execution of AI-Powered Workflows through a Chat window.

31 lines (30 loc) 911 B
import { get, post } from "@forgeflowai/chat/api/generic"; export async function loadPreviousSession(sessionId, options) { const method = options.webhookConfig?.method === "POST" ? post : get; return await method( `${options.webhookUrl}`, { action: "loadPreviousSession", [options.chatSessionKey]: sessionId, ...options.metadata ? { metadata: options.metadata } : {} }, { headers: options.webhookConfig?.headers } ); } export async function sendMessage(message, sessionId, options) { const method = options.webhookConfig?.method === "POST" ? post : get; return await method( `${options.webhookUrl}`, { action: "sendMessage", [options.chatSessionKey]: sessionId, [options.chatInputKey]: message, ...options.metadata ? { metadata: options.metadata } : {} }, { headers: options.webhookConfig?.headers } ); }