Im sure this is a simple fix but Im stuck…Im building an flow in order to bring appointments from GHL to LeapSalesPro.
When a user in Leap opens their calendar Leap sends a POST Request to N8N and expects and array back to map appointments. My issue is structuring the webhook response array back with all event/ appointment data regardless of the amount of appointments.
Current Flow
- Catch POST Hook
- Search Employee Database by Leap user ID & get GHL User ID
- Get UNIX Time (For Next Step)
- HTTPS GET request for search appointments buy date, time and GHL User ID
When the GHL HTTP GET Request Responds it could have 1 event or 30 events but all are nested under “events”
I then need to map data and send back ONE array with all appointments and data to Leap via the example array.
GHL GET HTTPS Response
[
{
"events": [
{
"appointmentStatus": "confirmed",
"assignedUserId": "HIDDEN",
"address": " 323 Hatton Avenue Collingswood NJ 08108",
"calendarId": "Ck2fE93EvpBzMMzkLIa1",
"contactId": "nGQ3kwHKbB6lfabloY3I",
"dateAdded": "2025-02-13T00:14:14.227Z",
"dateUpdated": "2025-02-13T00:14:14.027Z",
"endTime": "2025-02-13T11:00:00-05:00",
"groupId": "Uxefsnfp6V2ZXR9RW1iT",
"id": "kwOKgSOwmhgzZHRxX3Qs",
"locationId": "HIDDEN",
"notes": "",
"startTime": "2025-02-13T09:00:00-05:00",
"title": "Project Consultation with Timothy ( 323 Hatton Avenue)",
"assignedResources": [],
"isRecurring": false
}
],
"traceId": "50c3437c-ae72-4e25-a68c-2aeb4008847d"
}
]
Leap Expected Array Webhook Response
[
[
{
"display": false,
"type": "string",
"value": "abc123",
"appKey": "identifier"
},
{
"title": "Date",
"display": true,
"type": "appDate",
"value": "2018-07-10T12:30:00",
"dateFormat": "yyyy-MM-dd'T'HH:mm:ss"
},
{
"title": "Contact",
"display": true,
"type": "string",
"value": "John Doe",
"appKey": "name"
},
{
"title": "Street",
"display": true,
"type": "string",
"value": "123 Main Street",
"appKey": "addressStreet"
},
{
"title": "City",
"display": true,
"type": "string",
"value": "Baltimore",
"appKey": "addressCity"
},
{
"title": "State",
"display": true,
"type": "string",
"value": "MD",
"appKey": "addressState"
},
{
"title": "Zip Code",
"display": true,
"type": "string",
"value": "21122",
"appKey": "addressZip"
},
{
"title": "Notes",
"display": true,
"type": "string",
"value": "Interested in Roofing and Windows"
},
{
"display": false,
"type": "string",
"value": "443-555-5555",
"appKey": "phone"
},
{
"display": false,
"type": "string",
"value": "443-444-5555",
"appKey": "phone"
},
{
"display": false,
"type": "string",
"value": "[email protected]",
"appKey": "email"
},
{
"display": false,
"appKey": "apiSourceData",
"value": {
"leadSource": "Trade Show",
"opportunityId": "as6d5f4a5s1f56",
"contactId": "e5wrt46w5189e4",
"marketId": "wrh51w6fd51fg6"
}
}
],
[
{
"display": false,
"type": "string",
"value": "xyz789",
"appKey": "identifier"
},
{
"title": "Date",
"display": true,
"type": "appDate",
"value": "2018-07-11T16:30:00",
"dateFormat": "yyyy-MM-dd'T'HH:mm:ss"
},
{
"title": "Contact",
"display": true,
"type": "string",
"value": "Bob Smith",
"appKey": "name"
},
{
"title": "Street",
"display": true,
"type": "string",
"value": "789 Marahall Ave",
"appKey": "addressStreet"
},
{
"title": "City",
"display": true,
"type": "string",
"value": "Baltimore",
"appKey": "addressCity"
},
{
"title": "State",
"display": true,
"type": "string",
"value": "MD",
"appKey": "addressState"
},
{
"title": "Zip Code",
"display": true,
"type": "string",
"value": "21045",
"appKey": "addressZip"
},
{
"title": "Notes",
"display": true,
"type": "string",
"value": "Roof replacement"
},
{
"display": false,
"type": "string",
"value": "410-768-1688",
"appKey": "phone"
},
{
"display": false,
"type": "string",
"value": "410-654-3210",
"appKey": "phone"
},
{
"display": false,
"type": "string",
"value": "[email protected]",
"appKey": "email"
},
{
"display": false,
"appKey": "apiSourceData",
"value": {
"leadSource": "Internet",
"opportunityId": "s6dry51s6dfg1",
"contactId": "gr5k5f4g2ds1a84",
"marketId": "wer54ysd51g56sd4fg5"
}
}
]
]