UNPKG

n8n

Version:

n8n Workflow Automation Tool

27 lines 1.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.buildAskQuestionTool = buildAskQuestionTool; const tool_1 = require("@n8n/agents/tool"); const api_types_1 = require("@n8n/api-types"); function buildAskQuestionTool() { return new tool_1.Tool(api_types_1.ASK_QUESTION_TOOL_NAME) .description('Show a question card in the chat UI and suspend until the user answers. Use when ' + 'the request is ambiguous. Pass `options` as the known choices; for an open-ended ' + 'question pass an empty `options` array and the card shows only a freeform input. ' + 'Do NOT add your own "Other" option — the card always includes a freeform field, so ' + 'returned values may include user-entered text. Returns { values: string[] } with ' + 'selected option values and/or freeform text.') .input(api_types_1.askQuestionInputSchema) .suspend(api_types_1.askQuestionInputSchema) .resume(api_types_1.askQuestionResumeSchema) .handler(async (input, ctx) => { if (ctx.resumeData !== undefined) return ctx.resumeData; if (input.options.length === 1) { return { values: [input.options[0].value] }; } return await ctx.suspend(input); }) .build(); } //# sourceMappingURL=ask-question.tool.js.map