UNPKG

@n8n/n8n-nodes-langchain

Version:
175 lines (168 loc) 8.46 kB
/** * Chat Trigger Node - Version 1.3 * Runs the workflow when an n8n generated webchat is submitted */ export interface LcChatTriggerV13Params { /** * Whether the chat should be publicly available or only accessible through the manual chat interface * @default false */ public?: boolean | Expression<boolean>; /** * Mode * @displayOptions.show { public: [true] } * @default hostedChat */ mode?: 'hostedChat' | 'webhook' | Expression<string>; /** * The way to authenticate * @builderHint Default to 'none'. n8n exposes inbound trigger URLs publicly by design. Only select an authentication method when the user explicitly asks to authenticate inbound traffic. * @displayOptions.show { public: [true] } * @default none */ authentication?: 'basicAuth' | 'n8nUserAuth' | 'none' | Expression<string>; /** * Whether the triggering user must also have permission to execute the workflow in the project it belongs to * @displayOptions.show { authentication: ["n8nUserAuth"], mode: ["hostedChat"], public: [true] } * @default false */ requireExecuteAccess?: boolean | Expression<boolean>; /** * Whether to include the logged-in user's ID, email and name in the trigger output * @displayOptions.show { authentication: ["n8nUserAuth"], public: [true] } * @default false */ includeUserInOutput?: boolean | Expression<boolean>; /** * Default messages shown at the start of the chat, one per line * @displayOptions.show { mode: ["hostedChat"], public: [true] } */ initialMessages?: string | Expression<string>; /** * Whether to make the agent available in n8n Chat Hub for n8n instance users to chat with * @default false */ availableInChat?: boolean; /** * The icon of the agent on n8n Chat * @displayOptions.show { availableInChat: [true] } * @default {"type":"icon","value":"bot"} */ agentIcon?: { type: 'icon' | 'emoji'; value: string }; /** * The name of the agent on n8n Chat. Name of the workflow is used if left empty. * @displayOptions.show { availableInChat: [true] } */ agentName?: string; /** * The description of the agent on n8n Chat * @displayOptions.show { availableInChat: [true] } */ agentDescription?: string; /** * Suggested prompts shown to users in n8n Chat Hub to start a conversation with the agent * @displayOptions.show { availableInChat: [true] } * @default {} */ suggestedPrompts?: { /** Prompts */ prompts?: Array<{ /** Icon * @default {"type":"icon","value":"comment"} */ icon?: { type: 'icon' | 'emoji'; value: string }; /** Prompt Text */ text?: string; }>; }; /** * Options * @displayOptions.show { public: [false] } * @default {} */ options?: { /** Whether to allow file uploads in the chat * @default false */ allowFileUploads?: boolean | Expression<boolean>; /** Allowed file types for upload. Comma-separated list of &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types" target="_blank"&gt;MIME types&lt;/a&gt;. * @default * */ allowedFilesMimeTypes?: string | Expression<string>; /** When and how to respond to the chat * @builderHint 'streaming' (preferred for Agent-backed chats): the connected Agent streams its reply to the widget directly — no extra wiring. Place logging or side-effects on a PARALLEL branch off the trigger or Agent, never inline after the Agent. 'lastNode': the last-executed node's output is sent to the widget — that node MUST emit `{ output: '&lt;reply text&gt;' }` (typically the Agent itself, or a Set node re-shaping data). NEVER terminate the chain with a Data Table insert, HTTP Request, or other side-effect node — their output is not a chat reply and the widget will error. 'responseNodes' / 'responseNode': requires explicit response nodes inside the flow (`@n8n/n8n-nodes-langchain.chat` for chat-hub mode, `n8n-nodes-base.respondToWebhook` for webhook mode). * @displayOptions.show { /availableInChat: [false] } * @default lastNode */ responseMode?: 'lastNode' | 'responseNodes' | 'streaming' | Expression<string>; /** When and how to respond to the chat * @builderHint 'streaming' (preferred for Agent-backed chats): the connected Agent streams its reply to the widget directly — no extra wiring. Place logging or side-effects on a PARALLEL branch off the trigger or Agent, never inline after the Agent. 'lastNode': the last-executed node's output is sent to the widget — that node MUST emit `{ output: '&lt;reply text&gt;' }` (typically the Agent itself, or a Set node re-shaping data). NEVER terminate the chain with a Data Table insert, HTTP Request, or other side-effect node — their output is not a chat reply and the widget will error. 'responseNodes' / 'responseNode': requires explicit response nodes inside the flow (`@n8n/n8n-nodes-langchain.chat` for chat-hub mode, `n8n-nodes-base.respondToWebhook` for webhook mode). * @displayOptions.show { /availableInChat: [true] } * @default streaming */ responseMode?: 'streaming' | 'lastNode' | 'responseNodes' | Expression<string>; /** Whether to automatically save &lt;a href="https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.executiondata/" target="_blank"&gt;highlighted data&lt;/a&gt;. This data can then be used to filter executions in the Executions view. Available on Pro and Enterprise plans in n8n Cloud, and on Enterprise or registered Community Edition for self-hosted. Defaults to true. * @default true */ autoSaveHighlightedData?: boolean | Expression<boolean>; /** Comma-separated list of URLs allowed for cross-origin non-preflight requests. Use * (default) to allow all origins. * @displayOptions.show { /mode: ["hostedChat", "webhook"] } * @default * */ allowedOrigins?: string | Expression<string>; /** Shown as placeholder text in the chat input field * @displayOptions.show { /mode: ["hostedChat"] } * @default Type your question.. */ inputPlaceholder?: string | Expression<string>; /** If loading messages of a previous session should be enabled * @builderHint This ONLY rehydrates the chat widget UI when the user reopens it — it does NOT give the Agent memory. The Agent gets memory from its own memory subnode regardless of this setting. Only set to 'memory' if the user wants the widget to restore visible history on reload; if so, you MUST also attach a memory subnode to this trigger (use the same memory node as the Agent so widget history matches what the Agent remembers). Otherwise leave as 'notSupported'. * @default notSupported */ loadPreviousSession?: 'notSupported' | 'memory' | 'manually' | Expression<string>; /** Whether to show the welcome screen at the start of the chat * @displayOptions.show { /mode: ["hostedChat"] } * @default false */ showWelcomeScreen?: boolean | Expression<boolean>; /** Shown as part of the welcome screen, in the middle of the chat window * @displayOptions.show { showWelcomeScreen: [true], /mode: ["hostedChat"] } * @default New Conversation */ getStarted?: string | Expression<string>; /** Shown at the top of the chat, under the title * @displayOptions.show { /mode: ["hostedChat"] } * @default Start a chat. We're here to help you 24/7. */ subtitle?: string | Expression<string>; /** Shown at the top of the chat * @displayOptions.show { /mode: ["hostedChat"] } * @default Hi there! 👋 */ title?: string | Expression<string>; /** Override default styling of the public chat interface with CSS * @displayOptions.show { /mode: ["hostedChat"] } */ customCss?: string | Expression<string>; }; } export interface LcChatTriggerV13SubnodeConfig { /** * @displayOptions.show { options.loadPreviousSession: ["memory"] } */ memory: MemoryInstance; } export interface LcChatTriggerV13Credentials { httpBasicAuth: CredentialReference; } interface LcChatTriggerV13NodeBase { type: '@n8n/n8n-nodes-langchain.chatTrigger'; version: 1.3; isTrigger: true; } export type LcChatTriggerV13ParamsNode = LcChatTriggerV13NodeBase & { config: NodeConfig<LcChatTriggerV13Params> & { credentials?: LcChatTriggerV13Credentials } & { subnodes: LcChatTriggerV13SubnodeConfig }; }; export type LcChatTriggerV13Node = LcChatTriggerV13ParamsNode;