YUNOVA · AI Agents
Module 8: Agents in n8n
The AI Agent node in n8n
Key points
- n8n में AI Agent node एक chat model, memory और tools को जोड़कर agent बनाता है।
- System message agent की भूमिका और नियम तय करता है; user message हर बार आने वाला सवाल या input है।
- AI Agent node को किसी trigger से शुरू किया जाता है, जैसे chat trigger या webhook।
Giving the agent tools: HTTP, Google Sheets, Gmail
Key points
- AI Agent node में tools जोड़कर agent को काम करने की क्षमता मिलती है, जैसे HTTP Request, Google Sheets या Gmail।
- Google Sheets और Gmail के लिए पहले credentials जोड़ने पड़ते हैं, आमतौर पर Google account से OAuth के ज़रिए।
- HTTP Request tool से agent किसी भी API को call कर सकता है।
- हर tool का description साफ़ लिखें ताकि agent समझे कि उसे कब इस्तेमाल करना है।
Memory in n8n agents
Key points
- n8n में AI Agent node से memory sub-node जोड़ा जाता है, ताकि agent पिछली बातें याद रखे।
- Simple memory n8n के अंदर ही हाल के messages रखती है; स्थायी memory के लिए Postgres या Redis जैसे database वाले विकल्प होते हैं।
- Session ID से हर user की बातचीत अलग रखी जाती है, ताकि एक user की memory दूसरे में न मिले।
A Telegram or WhatsApp agent
Key points
- Telegram agent के लिए BotFather से bot बनाकर token लिया जाता है और n8n में Telegram trigger लगाया जाता है।
- आने वाला message AI Agent node को जाता है, और जवाब Telegram node से वापस user को भेजा जाता है।
- WhatsApp के लिए WhatsApp Business Platform (Meta) की setup ज़रूरी होती है, जो Telegram से ज़्यादा कदमों वाली है।
- User की chat ID को session ID बनाकर हर user की memory अलग रखें।
Testing and watching the executions
Key points
- n8n में workflow को test करके हर node का input और output देखा जा सकता है।
- Executions list में हर run का इतिहास रहता है: सफल हुआ या fail, और किस node पर रुका।
- Agent के tool calls और जवाबों को देखकर prompt या tool description सुधारें।