Call n8n Workflow Tool node#
Call n8n Workflow Tool node เป็น tool ที่ช่วยให้ agent สามารถรัน workflow อื่นใน n8n และดึงข้อมูล output ของ workflow นั้นมาใช้งานได้
ในหน้านี้จะมี parameter ของ node Call n8n Workflow Tool และลิงก์ไปยัง resource อื่นๆ
Parameter resolution in sub-nodes (การประมวลผล Parameter ใน sub-nodes)
Sub-nodes มีพฤติกรรมแตกต่างจาก node อื่นๆ เมื่อประมวลผลหลายรายการโดยใช้ expression
Node ส่วนใหญ่ รวมถึง root node จะรับ input กี่รายการก็ได้ ประมวลผลรายการเหล่านี้ และส่ง output ออกมา คุณสามารถใช้ expression เพื่ออ้างอิงถึง input item และ node จะประมวลผล expression สำหรับแต่ละ item ตามลำดับ ตัวอย่างเช่น หากมี input เป็นค่า name
ห้ารายการ expression {{ $json.name }}
จะถูกประมวลผลเป็นแต่ละชื่อตามลำดับ
ใน sub-nodes expression จะถูกประมวลผลเป็น item แรกเสมอ ตัวอย่างเช่น หากมี input เป็นค่า name
ห้ารายการ expression {{ $json.name }}
จะถูกประมวลผลเป็นชื่อแรกเสมอ
Node parameters#
Description#
ใส่คำอธิบาย custom code ของคุณ ตรงนี้จะช่วยบอก agent ว่าควรใช้ tool นี้เมื่อไหร่ เช่น
Call this tool to get a random color. The input should be a string with comma separated names of colors to exclude.
Source#
บอก n8n ว่าจะเรียก workflow ไหน คุณเลือกได้ระหว่าง:
- Database เพื่อเลือก workflow จากลิสต์หรือกรอก workflow ID
- Define Below แล้ว copy workflow JSON มาใส่
Workflow Inputs#
ถ้าใช้ Database เป็น workflow source หลังจากเลือก sub-workflow (และกำหนด Workflow Input Schema ใน sub-workflow) คุณจะสามารถกำหนด Workflow Inputs ได้
กดปุ่ม Refresh เพื่อดึง input field จาก sub-workflow
คุณสามารถกำหนดค่า input ของ workflow ได้หลายวิธี เช่น
- กำหนดค่าแบบ fix
- ใช้ expression เพื่ออ้างอิงข้อมูลจาก workflow ปัจจุบัน
- ให้ AI model กำหนด parameter โดยกดปุ่ม AI ด้านขวาของช่อง
- ใช้
$fromAI()
function ใน expression เพื่อควบคุมวิธีที่ model เติมข้อมูล หรือผสม input ที่ AI สร้างกับ input อื่น
ถ้าต้องการอ้างอิงข้อมูลจาก workflow ปัจจุบัน ให้ลาก field จาก input panel ไปยังช่องที่เปิด Expression mode
ถ้าอยากเริ่มใช้ $fromAI()
function ให้กดปุ่ม "Let the model define this parameter" ด้านขวาของช่อง แล้วใช้ปุ่ม X เพื่อกลับไปใช้ค่าที่ผู้ใช้กำหนดเอง ช่องจะเปลี่ยนเป็น expression field ที่มี $fromAI()
expression อยู่แล้ว คุณสามารถปรับแต่ง expression นี้ต่อได้ตามต้องการ
Templates and examples#
Related resources#
อ้างอิง LangChain's documentation on tools สำหรับข้อมูลเพิ่มเติมเกี่ยวกับ tools ใน LangChain
ดูเอกสาร Advanced AI ของ n8n
AI glossary#
- completion: Completions are the responses generated by a model like GPT.
- hallucinations: Hallucination in AI is when an LLM (large language model) mistakenly perceives patterns or objects that don't exist.
- vector database: A vector database stores mathematical representations of information. Use with embeddings and retrievers to create a database that your AI can access when answering questions.
- vector store: A vector store, or vector database, stores mathematical representations of information. Use with embeddings and retrievers to create a database that your AI can access when answering questions.