Describe the problem/error/question
The workflow below for scheduling a meeting on Google Calendar runs properly. However, it incorrectly schedules meetings or works sometimes, but doesnt work as expected sometimes. This is the payload the webhook is sending to the agent -
{
"Full_Name": "Rick T",
"Phone": "+14123788784",
"Preferred_time": "August 18th, 1 PM"
}
What is the error message (if any)?
Please share your workflow
'''{
"name": "Patient Schedule Apointment",
"nodes": [
{
"parameters": {
"sessionIdType": "customKey",
"sessionKey": "{{ $json[\"sessionId\"]}}",
"contextWindowLength": 1
},
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"typeVersion": 1.3,
"position": [
-32,
1008
],
"id": "69e9e526-6048-4954-ab15-54cff047e668",
"name": "Simple Memory",
"notesInFlow": false
},
{
"parameters": {
"model": {
"__rl": true,
"value": "gpt-3.5-turbo",
"mode": "list",
"cachedResultName": "gpt-3.5-turbo"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [
-160,
1008
],
"id": "a59c382e-7033-4090-808e-ccb89c919f79",
"name": "OpenAI Chat Model1",
"credentials": {
"openAiApi": {
"id": "MTFgzH1dOlBNhqrG",
"name": "OpenAi account 2"
}
}
},
{
"parameters": {
"respondWith": "allIncomingItems",
"options": {}
},
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.4,
"position": [
560,
784
],
"id": "d2762261-7936-4074-b5d9-078ab989331c",
"name": "Respond to Webhook"
},
{
"parameters": {
"calendar": {
"__rl": true,
"value": "[email protected]",
"mode": "list",
"cachedResultName": "[email protected]"
},
"start": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Start', ``, 'string') }}",
"end": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('End', ``, 'string') }}",
"additionalFields": {
"description": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Description', ``, 'string') }}",
"summary": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Summary', ``, 'string') }}"
}
},
"type": "n8n-nodes-base.googleCalendarTool",
"typeVersion": 1.3,
"position": [
336,
1008
],
"id": "eb4c4e3f-760d-42e2-9c8b-b4dcb1138961",
"name": "post_calendar",
"alwaysOutputData": true,
"credentials": {
"googleCalendarOAuth2Api": {
"id": "EaWwgOOIsYr9rgqq",
"name": "Google Calendar account 2"
}
}
},
{
"parameters": {
"httpMethod": "POST",
"path": "Schedule-appointment",
"responseMode": "responseNode",
"options": {}
},
"type": "n8n-nodes-base.webhook",
"typeVersion": 2.1,
"position": [
-384,
784
],
"id": "888a7996-21fb-4645-aaba-eadec6f64909",
"name": "Webhook",
"webhookId": "08f1e90c-ed98-459d-a643-3c2084285c9b"
},
{
"parameters": {
"promptType": "define",
"text": "=## Request Data\n\n{{ JSON.stringify($json.body, null, 2)}}",
"options": {
"systemMessage": "## Role\n\nYou are an AI agent responsible for handling back office operations at the Doctor's office. You must make a decision about the data you receive and make a call into the appropriate tool in order to process this request and return the appropriate data necessary.\n\nYou should look at the provided `tool` value in the request body to help decided which tool to use.\n\nPay close attention to the constraints for number of times a tool is able to be used.\n\nYou have secure access to the following internal tools:\n - `think` → you MUST use this to think carefully about how to handle the provided request data. This tool must be used on every turn and tool call interaction.\n - `get_calendar` → returns true/false availability on the Calendar for the given start timestamp in ET (Eastern Time). **For availability requests, you MUST call this tool multiple times to find AT LEAST 2 available timeslots if they exist.** Matches the `get_calendar` tool value included in the request.\n - `post_calendar` → creates a 30 min appointment event for the provided start time. This tool may only be called ONCE (1 time) in a given request. Do NOT use this tool multiple times. Matches the `post_calendar` tool value included in the request. If you use this tool more than once, your task will be considered a FAILURE.\n\n## Special Instructions for get_calendar Tool\n\nWhen handling availability requests:\n\n1. **Always aim to return 2 available timeslots** when possible\n2. **Call get_calendar multiple times** to check different time slots on the requested date\n3. **Search strategy:**\n - Start with the requested time (if provided)\n - If that's not available, check nearby times in 30-minute increments\n - Check both earlier and later times on the same day\n - Continue checking until you find 2 available slots OR exhaust reasonable options\n\n4. **Response format:** Return an array of available timeslots in ISO format (Eastern Time Zone ET):\n ```json\n {\n \"availableSlots\": [\n \"2024-01-15T14:00:00Z\",\n \"2024-01-15T16:00:00Z\"\n ]\n }\n ```\n\n5. **If fewer than 2 slots are found:**\n - Return whatever available slots you found (even if just 1)\n - It's better to return 1 slot than none\n\n6. **Time checking sequence example:**\n - If user requests \"2:00 PM on Tuesday\"\n - Check: 2:00 PM, 1:30 PM, 2:30 PM, 1:00 PM, 3:00 PM, 12:30 PM, 3:30 PM, etc.\n - Stop when you have 2 available slots or have checked reasonable business hours\n\n7. **Business hours assumption:** \n - Check times between 8:00 AM and 5:00 PM unless specified otherwise\n - Skip lunch hour (12:00-1:00 PM) if applicable\n\nRemember: The get_calendar tool can be called multiple times for availability requests, but post_calendar must only be called ONCE per request.\n\nRemember: All times are in ET (Eastern Time Zone)",
"returnIntermediateSteps": true
}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 1.9,
"position": [
24,
784
],
"id": "68b824cd-1b4d-4f4f-81fc-987f499d2334",
"name": "AI Agent",
"alwaysOutputData": true
},
{
"parameters": {},
"type": "@n8n/n8n-nodes-langchain.toolThink",
"typeVersion": 1.1,
"position": [
224,
1008
],
"id": "38b22024-199b-45c0-8be8-0615d86fd8eb",
"name": "Think"
},
{
"parameters": {
"descriptionType": "manual",
"toolDescription": "Returns the schedule for the doctor for the next 2 weeks",
"operation": "getAll",
"calendar": {
"__rl": true,
"value": "[email protected]",
"mode": "list",
"cachedResultName": "[email protected]"
},
"returnAll": true,
"options": {
"timeZone": {
"__rl": true,
"value": "America/New_York",
"mode": "list",
"cachedResultName": "America/New_York"
}
}
},
"type": "n8n-nodes-base.googleCalendarTool",
"typeVersion": 1.3,
"position": [
-384,
1112
],
"id": "b0a190b9-99c1-45ac-85a7-9bf38d86954d",
"name": "get_calendar_og",
"credentials": {
"googleCalendarOAuth2Api": {
"id": "EaWwgOOIsYr9rgqq",
"name": "Google Calendar account 2"
}
}
},
{
"parameters": {
"operation": "getAll",
"calendar": {
"__rl": true,
"value": "[email protected]",
"mode": "list",
"cachedResultName": "[email protected]"
},
"timeMin": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('After', `The start timestamp for the appointment.`, 'string') }}",
"timeMax": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Before', `The end time will always be the Start Time plus 30 minutes.`, 'string') }}",
"options": {
"timeZone": {
"__rl": true,
"value": "America/New_York",
"mode": "list",
"cachedResultName": "America/New_York"
}
}
},
"type": "n8n-nodes-base.googleCalendarTool",
"typeVersion": 1.3,
"position": [
96,
1008
],
"id": "d57fad01-69b7-4859-ab34-3b387ae06d4f",
"name": "get_calendar",
"credentials": {
"googleCalendarOAuth2Api": {
"id": "EaWwgOOIsYr9rgqq",
"name": "Google Calendar account 2"
}
}
}
],
"pinData": {
"Webhook": [
{
"json": {
"headers": {
"host": "rrohit992.app.n8n.cloud",
"user-agent": "ElevenLabs/1.0",
"content-length": "161",
"accept": "*/*",
"accept-encoding": "gzip, br",
"cdn-loop": "cloudflare; loops=1; subreqs=1",
"cf-connecting-ip": "34.59.11.47",
"cf-ew-via": "15",
"cf-ipcountry": "US",
"cf-ray": "96bb76dc8331c5fe-ORD",
"cf-visitor": "{\"scheme\":\"https\"}",
"cf-worker": "n8n.cloud",
"content-type": "application/json",
"x-forwarded-for": "34.59.11.47, 172.70.194.154",
"x-forwarded-host": "rrohit992.app.n8n.cloud",
"x-forwarded-port": "443",
"x-forwarded-proto": "https",
"x-forwarded-server": "traefik-prod-users-gwc-33-6b64989c5-s7rlk",
"x-is-trusted": "yes",
"x-real-ip": "34.59.11.47"
},
"params": {},
"query": {},
"body": {
"Phone": "+14123788780",
"Preferred_time": "August 12th 11 AM",
"Other_information": "",
"Full_Name": "Rohit Ramesh"
},
"webhookUrl": "https://rrohit992.app.n8n.cloud/webhook/Schedule-appointment",
"executionMode": "production"
}
}
]
},
"connections": {
"Simple Memory": {
"ai_memory": [
[
{
"node": "AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"OpenAI Chat Model1": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"post_calendar": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Webhook": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"AI Agent": {
"main": [
[
{
"node": "Respond to Webhook",
"type": "main",
"index": 0
}
]
]
},
"Think": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"get_calendar_og": {
"ai_tool": [
[]
]
},
"get_calendar": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1",
"callerPolicy": "workflowsFromSameOwner",
"executionTimeout": -1
},
"versionId": "0d9220aa-331a-4f6c-8423-cc72fc1c4884",
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "34ced75dd427ccf2d045c820903395fe9550d469232d0c251dd21db4b39a9775"
},
"id": "JHWwRzBxODvNFcfE",
"tags": []
}'''
Share the output returned by the last node
Information on your n8n setup
- n8n version:
- Database (default: SQLite):
- n8n EXECUTIONS_PROCESS setting (default: own, main):
- Running n8n via (Docker, npm, n8n cloud, desktop app):
- Operating system: