调用 API 获取数据(Call an API to fetch data)#
使用 n8n 从任何 API 获取数据到你的 AI。该工作流使用 聊天触发器 提供聊天界面,并使用 调用 n8n 工作流工具 调用第二个工作流,该工作流会调用 API。第二个工作流使用 AI 功能,根据用户的查询优化 API 请求。
🌐 Use n8n to bring data from any API to your AI. This workflow uses the Chat Trigger to provide the chat interface, and the Call n8n Workflow Tool to call a second workflow that calls the API. The second workflow uses AI functionality to refine the API request based on the user's query.
Workflow preview placeholder.
主要功能(Key features)#
此工作流程使用:
🌐 This workflow uses:
- 聊天触发器:启动您的工作流程并回应用户的聊天互动。该节点提供了一个可自定义的聊天界面。
- 代理:AI 工作流程的关键部分。代理与工作流程中的其他组件进行交互,并决定使用哪些工具。
- 调用 n8n 工作流工具:将 n8n 工作流作为自定义工具接入。在 AI 中,工具是 AI 用来与外界交互的接口(在此情况下,即你的工作流提供的数据)。AI 模型使用该工具来获取超出其内置数据集的信息。
- 一个带有自动修复输出解析器和结构化输出解析器的基础LLM链,用于读取用户的查询并根据用户输入设置API调用参数。
使用示例(Using the example)#
To load the template into your n8n instance:
- Download the workflow JSON file.
- Open a new workflow in your n8n instance.
- Copy in the JSON, or select Workflow menu
> Import from file....
The example workflows use Sticky Notes to guide you:
- Yellow: notes and information.
- Green: instructions to run the workflow.
- Orange: you need to change something to make the workflow work.
- Blue: draws attention to a key feature of the example.