by Webble Templates
Use Template/**
* @param {object} args
* @param {string} args.apiKey
* @param {string} args.start Time starting from which available slots should be checked.
Must be in UTC timezone as ISO 8601 datestring.
You can pass date without hours which defaults to start of day or specify hours:
2024-08-13 (will have hours 00:00:00 aka at very beginning of the date) or you can specify hours manually like 2024-08-13T09:00:00Z.
* @param {string} args.end Time until which available slots should be checked.
Must be in UTC timezone as ISO 8601 datestring.
You can pass date without hours which defaults to end of day or specify hours:
2024-08-20 (will have hours 23:59:59 aka at the very end of the date) or you can specify hours manually like 2024-08-20T18:00:00Z.
* @param {string} args.organizationSlug The slug of the organization to which user with username belongs or team with teamSlug belongs.
* @param {string} args.username The username of the user who owns event type with eventTypeSlug - used when slots are checked for individual user event type.
* @param {string} args.teamSlug The slug of the team who owns event type with eventTypeSlug - used when slots are checked for team event type.
* @param {string} args.eventTypeSlug The slug of the event type for which available slots should be checked. If slug is provided then username or teamSlug must be provided too and if relevant organizationSlug too.
* @param {string} args.eventTypeId The ID of the event type for which available slots should be checked.
* @param {string} args.usernames The usernames for which available slots should be checked separated by a comma.
Checking slots by usernames is used mainly for dynamic events where there is no specific event but we just want to know when 2 or more people are available.
Must contain at least 2 usernames.
* @param {string} args.format Format of slot times in response. Use 'range' to get start and end times. Use 'time' or omit this query parameter to get only start time.
* @param {string} args.duration If event type has multiple possible durations then you can specify the desired duration here. Also, if you are fetching slots for a dynamic event then you can specify the duration her which defaults to 30, meaning that returned slots will be each 30 minutes long.
* @param {string} args.timezone Time zone in which the available slots should be returned. Defaults to UTC.
*/
async function main(args) {
let {apiKey, ...payload} = args;
const headers = {
"Authorization": `Bearer ${apiKey}`,
"Content-Type": "application/json",
"cal-api-version": "2024-09-04"
}
const searchParams = new URLSearchParams([
...Array.from(Object.entries(payload)),
]).toString();
const result = await fetch(`https://api.cal.com/v2/slots?${searchParams}`, { method: "GET", headers })
.then(response => response.json())
.catch(err => console.error(err));
return {output: result};
}
Want to see more chatbot templates and resources?
View more templates