#WEBHOOK ActivePieces ↔ TRAFFT
→ https//cloud.activepieces.com/api/v1/webhooks/doremido
{
"body": {
"extras": [
"Extra 1, $20, 30min, x2",
"Extra 2, $30, 10min, x1"
],
"bookingUuid": "BOOKING UID HERE",
"serviceName": "Service Name",
"customFields": [
"Custom Field 1: Custom Fields 1 Value A, Custom Field 1 Value B",
"Custom Field 2: Custom Fields 1 Value A"
],
"locationName": "Location Name",
"servicePrice": "25",
"customerEmail": "customer_example@example.example",
"customerPhone": "+000000000",
"employeeEmail": "employee_example@example.example",
"employeePhone": "+000000000",
"locationPhone": "+000000000",
"locationAddress": "Location Address",
"serviceCategory": "Service Category Name",
"serviceDuration": "300",
"appointmentPrice": "25",
"customerFullName": "Customer Full Name",
"customerLastName": "Customer Last Name",
"employeeFullName": "Employee Full Name",
"employeeLastName": "Employee Last Name",
"appointmentStatus": "Approved",
"customerFirstName": "Customer First Name",
"employeeFirstName": "Employee First Name",
"appointmentEndDate": "July 16, 2022",
"appointmentEndTime": "6:00 pm",
"appointmentStartDate": "July 16, 2022",
"appointmentStartTime": "5:00 pm",
"appointmentEndDateTime": "July 16, 2022 6:00 pm",
"appointmentStartDateTime": "July 16, 2022 5:00 pm"
},
#Code for time conversion Trafft native to Sessions native
export const code = async (inputs) => {
const inputStartDateTime = inputs.StartDateTime;
const inputEndDateTime = inputs.EndDateTime;
const convertTo24HourFormat = (dateTime: string) => {
const [_, month, day, year, hours, minutes, period] = dateTime.match(/(\w+) (\d+), (\d+) (\d+):(\d+) (\w+)/) || [];
let hours24 = parseInt(hours, 10);
if (period.toLowerCase() === "pm" && hours24 !== 12) {
hours24 += 12;
} else if (period.toLowerCase() === "am" && hours24 === 12) {
hours24 = 0;
}
const monthNumber = new Date(Date.parse(month + " 1, 2012")).getMonth() + 1;
const monthString = monthNumber.toString().padStart(2, "0");
const dayString = day.padStart(2, "0");
const isoString = `${year}-${monthString}-${dayString}T${hours24.toString().padStart(2, "0")}:${minutes}:00.000Z`;
return isoString;
};
const startDateTime24 = convertTo24HourFormat(inputStartDateTime);
const endDateTime24 = convertTo24HourFormat(inputEndDateTime);
return {
startDateTime24: startDateTime24,
endDateTime24: endDateTime24,
};
};
Output Example
{
"endDateTime24": "2022-07-16T18:00:00.000Z",
"startDateTime24": "2022-07-16T17:00:00.000Z"
}
#HTTP REQUEST - API Call to Sessions
#Login Info
ActivePieces → Send HTTP Post
→ https://api.app.sessions.us/api/sessions
->HEADER KEY “x-api-key”
->HEADER Value “INSERT API KEY HERE”
#api call to sessions.us to create a session
{
"name": "New Session",
"startAt": "{{step_1['startDateTime24']}}",
"plannedEnd": "{{step_1['endDateTime24']}}",
"description": null,
"timeZone": "America/New_York",
"quickSession": false,
"reminders": [],
"participants": []
}
VS
#/api/sessions API DOCUMENTATION
{
"name": "New Session",
"startAt": "2023-09-19T15:48:06.372Z",
"plannedEnd": "2023-09-19T15:48:06.372Z",
"description": null,
"timeZone": "Europe/Bucharest",
"quickSession": false,
"reminders": [],
"participants": []
}