n8n
Version:
n8n Workflow Automation Tool
26 lines • 1.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildAskQuestionTool = buildAskQuestionTool;
const agents_1 = require("@n8n/agents");
const api_types_1 = require("@n8n/api-types");
function buildAskQuestionTool() {
return new agents_1.Tool(api_types_1.ASK_QUESTION_TOOL_NAME)
.description('Show a multiple-choice card in the chat UI and suspend until the user picks an ' +
'answer. Use when the request is ambiguous and the answer is one (or more) of a ' +
'known list of options. The UI also includes an Other field, so returned values ' +
'may include user-entered freeform text when the listed options are incomplete. ' +
'Returns { values: string[] } with selected option values and/or Other 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