Instead of using basic βif-this-then-thatβ chatbots that break when a user asks a complex question, this workflow uses a fully autonomous AI Agent. It can dynamically conversationally route, remember context, and execute side-tasks like checking a real calendar.
To get this running, here is what you need to configure in the workflow:
Step 1: Get Your API Keys
Step 2: Connect Your Calendar (The Tools)
Availability Tool and Booking Tool.Step 3: Customize the Prompt
gpt-4o combined with a Window Buffer Memory so it remembers previous messages in the chat.Note: Users can literally copy the code block below and paste it directly into an empty n8n canvas!
{
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "ig-webhook",
"options": {}
},
"name": "Instagram Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 1,
"position": [200, 300]
},
{
"parameters": {
"promptType": "define",
"text": "={{ $json.body.message }}",
"options": {
"systemMessage": "You are a helpful booking assistant for an agency. Your job is to: 1) Ask intake questions (location, format). 2) Qualify their budget. 3) Offer available times from the calendar tool. 4) Book the appointment using the booking tool."
}
},
"name": "AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 1,
"position": [460, 300]
},
{
"parameters": {
"model": "gpt-4o",
"options": {}
},
"name": "OpenAI Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1,
"position": [440, 520]
},
{
"parameters": {
"sessionId": "={{ $json.body.sender_id }}"
},
"name": "Window Buffer Memory",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"typeVersion": 1,
"position": [580, 520]
},
{
"parameters": {
"name": "check_availability",
"description": "Checks the calendar for available appointment slots."
},
"name": "Availability Tool",
"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
"typeVersion": 1,
"position": [720, 520]
},
{
"parameters": {
"name": "book_appointment",
"description": "Books a qualified user into the calendar."
},
"name": "Booking Tool",
"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
"typeVersion": 1,
"position": [860, 520]
}
],
"connections": {
"Instagram Webhook": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Window Buffer Memory": {
"ai_memory": [
[
{
"node": "AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"Availability Tool": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Booking Tool": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
}
}
}