first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"node": "n8n-nodes-base.calendlyTrigger",
|
||||
"nodeVersion": "1.0",
|
||||
"codexVersion": "1.0",
|
||||
"categories": ["Productivity", "Utility"],
|
||||
"resources": {
|
||||
"credentialDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/integrations/builtin/credentials/calendly/"
|
||||
}
|
||||
],
|
||||
"primaryDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/integrations/builtin/trigger-nodes/n8n-nodes-base.calendlytrigger/"
|
||||
}
|
||||
],
|
||||
"generic": [
|
||||
{
|
||||
"label": "How to get started with CRM automation (with 3 no-code workflow ideas",
|
||||
"icon": "👥",
|
||||
"url": "https://n8n.io/blog/how-to-get-started-with-crm-automation-and-no-code-workflow-ideas/"
|
||||
},
|
||||
{
|
||||
"label": "5 tasks you can automate with the new Notion API ",
|
||||
"icon": "⚡️",
|
||||
"url": "https://n8n.io/blog/5-tasks-you-can-automate-with-notion-api/"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,293 @@
|
||||
import type {
|
||||
IHookFunctions,
|
||||
IWebhookFunctions,
|
||||
IDataObject,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
IWebhookResponseData,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeConnectionTypes } from 'n8n-workflow';
|
||||
|
||||
import { calendlyApiRequest, getAuthenticationType } from './GenericFunctions';
|
||||
|
||||
export class CalendlyTrigger implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'Calendly Trigger',
|
||||
name: 'calendlyTrigger',
|
||||
icon: 'file:calendly.svg',
|
||||
group: ['trigger'],
|
||||
version: 1,
|
||||
description: 'Starts the workflow when Calendly events occur',
|
||||
defaults: {
|
||||
name: 'Calendly Trigger',
|
||||
},
|
||||
inputs: [],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
credentials: [
|
||||
{
|
||||
name: 'calendlyApi',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: ['apiKey'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'calendlyOAuth2Api',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: ['oAuth2'],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
webhooks: [
|
||||
{
|
||||
name: 'default',
|
||||
httpMethod: 'POST',
|
||||
responseMode: 'onReceived',
|
||||
path: 'webhook',
|
||||
},
|
||||
],
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Authentication',
|
||||
name: 'authentication',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-display-name-miscased
|
||||
name: 'OAuth2 (recommended)',
|
||||
value: 'oAuth2',
|
||||
},
|
||||
{
|
||||
name: 'API Key or Personal Access Token',
|
||||
value: 'apiKey',
|
||||
},
|
||||
],
|
||||
default: 'apiKey',
|
||||
},
|
||||
{
|
||||
displayName:
|
||||
'Action required: Calendly will discontinue API Key authentication on May 31, 2025. Update node to use OAuth2 authentication now to ensure your workflows continue to work.',
|
||||
name: 'deprecationNotice',
|
||||
type: 'notice',
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: ['apiKey'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Scope',
|
||||
name: 'scope',
|
||||
type: 'options',
|
||||
default: 'user',
|
||||
required: true,
|
||||
hint: 'Ignored if you are using an API Key',
|
||||
options: [
|
||||
{
|
||||
name: 'Organization',
|
||||
value: 'organization',
|
||||
description: 'Triggers the webhook for all subscribed events within the organization',
|
||||
},
|
||||
{
|
||||
name: 'User',
|
||||
value: 'user',
|
||||
description:
|
||||
'Triggers the webhook for subscribed events that belong to the current user',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Events',
|
||||
name: 'events',
|
||||
type: 'multiOptions',
|
||||
options: [
|
||||
{
|
||||
name: 'Event Created',
|
||||
value: 'invitee.created',
|
||||
description: 'Receive notifications when a new Calendly event is created',
|
||||
},
|
||||
{
|
||||
name: 'Event Canceled',
|
||||
value: 'invitee.canceled',
|
||||
description: 'Receive notifications when a Calendly event is canceled',
|
||||
},
|
||||
],
|
||||
default: [],
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
const events = this.getNodeParameter('events') as string[];
|
||||
|
||||
const authenticationType = await getAuthenticationType.call(this);
|
||||
|
||||
// remove condition once API Keys are deprecated
|
||||
if (authenticationType === 'apiKey') {
|
||||
const endpoint = '/hooks';
|
||||
const { data } = await calendlyApiRequest.call(this, 'GET', endpoint, {});
|
||||
|
||||
for (const webhook of data) {
|
||||
if (webhook.attributes.url === webhookUrl) {
|
||||
for (const event of events) {
|
||||
if (!webhook.attributes.events.includes(event)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Set webhook-id to be sure that it can be deleted
|
||||
webhookData.webhookId = webhook.id as string;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (authenticationType === 'accessToken') {
|
||||
const scope = this.getNodeParameter('scope', 0) as string;
|
||||
const { resource } = await calendlyApiRequest.call(this, 'GET', '/users/me');
|
||||
|
||||
const qs: IDataObject = {};
|
||||
|
||||
if (scope === 'user') {
|
||||
qs.scope = 'user';
|
||||
qs.organization = resource.current_organization;
|
||||
qs.user = resource.uri;
|
||||
}
|
||||
|
||||
if (scope === 'organization') {
|
||||
qs.scope = 'organization';
|
||||
qs.organization = resource.current_organization;
|
||||
}
|
||||
|
||||
const endpoint = '/webhook_subscriptions';
|
||||
const { collection } = await calendlyApiRequest.call(this, 'GET', endpoint, {}, qs);
|
||||
|
||||
for (const webhook of collection) {
|
||||
if (
|
||||
webhook.callback_url === webhookUrl &&
|
||||
events.length === webhook.events.length &&
|
||||
events.every((event: string) => webhook.events.includes(event))
|
||||
) {
|
||||
webhookData.webhookURI = webhook.uri;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
async create(this: IHookFunctions): Promise<boolean> {
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||
const events = this.getNodeParameter('events') as string[];
|
||||
|
||||
const authenticationType = await getAuthenticationType.call(this);
|
||||
|
||||
// remove condition once API Keys are deprecated
|
||||
if (authenticationType === 'apiKey') {
|
||||
const endpoint = '/hooks';
|
||||
|
||||
const body = {
|
||||
url: webhookUrl,
|
||||
events,
|
||||
};
|
||||
|
||||
const responseData = await calendlyApiRequest.call(this, 'POST', endpoint, body);
|
||||
|
||||
if (responseData.id === undefined) {
|
||||
// Required data is missing so was not successful
|
||||
return false;
|
||||
}
|
||||
|
||||
webhookData.webhookId = responseData.id as string;
|
||||
}
|
||||
|
||||
if (authenticationType === 'accessToken') {
|
||||
const scope = this.getNodeParameter('scope', 0) as string;
|
||||
const { resource } = await calendlyApiRequest.call(this, 'GET', '/users/me');
|
||||
|
||||
const body: IDataObject = {
|
||||
url: webhookUrl,
|
||||
events,
|
||||
organization: resource.current_organization,
|
||||
scope,
|
||||
};
|
||||
|
||||
if (scope === 'user') {
|
||||
body.user = resource.uri;
|
||||
}
|
||||
|
||||
const endpoint = '/webhook_subscriptions';
|
||||
const responseData = await calendlyApiRequest.call(this, 'POST', endpoint, body);
|
||||
|
||||
if (responseData?.resource === undefined || responseData?.resource?.uri === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
webhookData.webhookURI = responseData.resource.uri;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
async delete(this: IHookFunctions): Promise<boolean> {
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
const authenticationType = await getAuthenticationType.call(this);
|
||||
|
||||
// remove condition once API Keys are deprecated
|
||||
if (authenticationType === 'apiKey') {
|
||||
if (webhookData.webhookId !== undefined) {
|
||||
const endpoint = `/hooks/${webhookData.webhookId}`;
|
||||
|
||||
try {
|
||||
await calendlyApiRequest.call(this, 'DELETE', endpoint);
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove from the static workflow data so that it is clear
|
||||
// that no webhooks are registered anymore
|
||||
delete webhookData.webhookId;
|
||||
}
|
||||
}
|
||||
|
||||
if (authenticationType === 'accessToken') {
|
||||
if (webhookData.webhookURI !== undefined) {
|
||||
try {
|
||||
await calendlyApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
'',
|
||||
{},
|
||||
{},
|
||||
webhookData.webhookURI as string,
|
||||
);
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
delete webhookData.webhookURI;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
|
||||
const bodyData = this.getBodyData();
|
||||
return {
|
||||
workflowData: [this.helpers.returnJsonArray(bodyData)],
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import type {
|
||||
IDataObject,
|
||||
IExecuteFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
IHookFunctions,
|
||||
IWebhookFunctions,
|
||||
IHttpRequestMethods,
|
||||
IRequestOptions,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
function getAuthenticationTypeFromApiKey(data: string): 'accessToken' | 'apiKey' {
|
||||
// The access token is a JWT, so it will always include dots to separate
|
||||
// header, payoload and signature.
|
||||
return data.includes('.') ? 'accessToken' : 'apiKey';
|
||||
}
|
||||
|
||||
export async function getAuthenticationType(
|
||||
this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions,
|
||||
): Promise<'accessToken' | 'apiKey'> {
|
||||
const authentication = this.getNodeParameter('authentication', 0) as string;
|
||||
if (authentication === 'apiKey') {
|
||||
const { apiKey } = await this.getCredentials<{ apiKey: string }>('calendlyApi');
|
||||
return getAuthenticationTypeFromApiKey(apiKey);
|
||||
} else {
|
||||
return 'accessToken';
|
||||
}
|
||||
}
|
||||
|
||||
export async function calendlyApiRequest(
|
||||
this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions,
|
||||
method: IHttpRequestMethods,
|
||||
resource: string,
|
||||
|
||||
body: any = {},
|
||||
query: IDataObject = {},
|
||||
uri?: string,
|
||||
option: IDataObject = {},
|
||||
): Promise<any> {
|
||||
const authenticationType = await getAuthenticationType.call(this);
|
||||
|
||||
const headers: IDataObject = {
|
||||
'Content-Type': 'application/json',
|
||||
};
|
||||
|
||||
let endpoint = 'https://api.calendly.com';
|
||||
|
||||
// remove once API key is deprecated
|
||||
if (authenticationType === 'apiKey') {
|
||||
endpoint = 'https://calendly.com/api/v1';
|
||||
}
|
||||
|
||||
let options: IRequestOptions = {
|
||||
headers,
|
||||
method,
|
||||
body,
|
||||
qs: query,
|
||||
uri: uri || `${endpoint}${resource}`,
|
||||
json: true,
|
||||
};
|
||||
|
||||
if (!Object.keys(body as IDataObject).length) {
|
||||
delete options.form;
|
||||
}
|
||||
if (!Object.keys(query).length) {
|
||||
delete options.qs;
|
||||
}
|
||||
options = Object.assign({}, options, option);
|
||||
|
||||
const credentialsType =
|
||||
(this.getNodeParameter('authentication', 0) as string) === 'apiKey'
|
||||
? 'calendlyApi'
|
||||
: 'calendlyOAuth2Api';
|
||||
return await this.helpers.requestWithAuthentication.call(this, credentialsType, options);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 525.8 535.73"><defs><style>.cls-2{fill:#006bff}.cls-3{fill:#0ae9ef}</style></defs><g id="Layer_2" data-name="Layer 2"><g id="Logo_assets" data-name="Logo assets"><g id="Brand_mark" data-name="Brand mark"><path d="m443.74 337.62-27.16 47.05a139.52 139.52 0 0 1-120.82 69.75h-54.33a139.52 139.52 0 0 1-120.82-69.75l-27.16-47.05a139.52 139.52 0 0 1 0-139.51l27.16-47.05A139.53 139.53 0 0 1 241.43 81.3h54.33a139.53 139.53 0 0 1 120.82 69.76l27.16 47.05a139 139 0 0 1 8.55 17.55c0 .12.09.23.13.35a102.15 102.15 0 0 0 44.33-18.24c0-.14-.08-.28-.13-.43a237.8 237.8 0 0 0-33.29-67.58 240.7 240.7 0 0 0-52-53.48 239.3 239.3 0 0 0-312.68 360.8 239.43 239.43 0 0 0 398-98.69c.05-.15.09-.29.13-.43a102.15 102.15 0 0 0-44.33-18.24c0 .12-.09.23-.13.35a139 139 0 0 1-8.58 17.55" style="fill:none"/><path d="M360.4 347.4c-17 15.09-38.21 33.87-76.78 33.87h-23c-27.88 0-53.23-10.12-71.37-28.49-17.72-17.94-27.48-42.5-27.48-69.16v-31.51c0-26.66 9.76-51.22 27.48-69.16 18.14-18.37 43.49-28.49 71.37-28.49h23c38.57 0 59.76 18.78 76.78 33.87 17.65 15.65 32.9 29.16 73.52 29.16a116 116 0 0 0 18.5-1.48c0-.12-.08-.23-.13-.35a139 139 0 0 0-8.55-17.55l-27.16-47.05A139.53 139.53 0 0 0 295.76 81.3h-54.33a139.53 139.53 0 0 0-120.82 69.76l-27.16 47.05a139.52 139.52 0 0 0 0 139.51l27.16 47.05a139.52 139.52 0 0 0 120.82 69.75h54.33a139.52 139.52 0 0 0 120.82-69.75l27.16-47.05a139 139 0 0 0 8.55-17.55c0-.12.09-.23.13-.35a116 116 0 0 0-18.5-1.48c-40.62 0-55.87 13.51-73.52 29.16" class="cls-2"/><path d="M283.62 183h-23c-42.42 0-70.3 30.3-70.3 69.09v31.51c0 38.79 27.88 69.09 70.3 69.09h23c61.82 0 57-63 150.3-63a144 144 0 0 1 26.37 2.41 139.4 139.4 0 0 0 0-48.46 143.3 143.3 0 0 1-26.37 2.42c-93.33-.01-88.48-63.06-150.3-63.06" class="cls-2"/><path d="M513.91 315.13a130.2 130.2 0 0 0-53.62-23c0 .16-.05.32-.08.47a138.5 138.5 0 0 1-7.79 27.16A102.15 102.15 0 0 1 496.75 338c0 .14-.08.28-.13.43A237.8 237.8 0 0 1 463.33 406a240.7 240.7 0 0 1-52 53.48A239.3 239.3 0 0 1 98.65 98.65a239.43 239.43 0 0 1 398 98.69c.05.15.09.29.13.43A102.15 102.15 0 0 1 452.42 216a139.4 139.4 0 0 1 7.8 27.18c0 .15 0 .3.07.44a129.94 129.94 0 0 0 53.62-23c15.29-11.31 12.33-24.09 10-31.65C490.22 79.52 388.33 0 267.86 0 119.93 0 0 119.93 0 267.86s119.93 267.87 267.86 267.87c120.47 0 222.36-79.52 256-188.94 2.38-7.56 5.34-20.34-9.95-31.66" class="cls-2"/><path d="M452.42 216a116 116 0 0 1-18.5 1.48c-40.62 0-55.87-13.51-73.52-29.16-17-15.09-38.21-33.87-76.78-33.87h-23c-27.88 0-53.23 10.12-71.37 28.49-17.72 17.94-27.48 42.5-27.48 69.16v31.51c0 26.66 9.76 51.22 27.48 69.16 18.14 18.37 43.49 28.49 71.37 28.49h23c38.57 0 59.76-18.78 76.78-33.87 17.65-15.65 32.9-29.16 73.52-29.16a116 116 0 0 1 18.5 1.48 138.5 138.5 0 0 0 7.79-27.16c0-.15.06-.31.08-.47a144 144 0 0 0-26.37-2.41c-93.33 0-88.48 63-150.3 63h-23c-42.42 0-70.3-30.3-70.3-69.09v-31.47c0-38.79 27.88-69.09 70.3-69.09h23c61.82 0 57 63 150.3 63a143.3 143.3 0 0 0 26.37-2.42c0-.14 0-.29-.07-.44a139.4 139.4 0 0 0-7.8-27.16" class="cls-3"/><path d="M452.42 216a116 116 0 0 1-18.5 1.48c-40.62 0-55.87-13.51-73.52-29.16-17-15.09-38.21-33.87-76.78-33.87h-23c-27.88 0-53.23 10.12-71.37 28.49-17.72 17.94-27.48 42.5-27.48 69.16v31.51c0 26.66 9.76 51.22 27.48 69.16 18.14 18.37 43.49 28.49 71.37 28.49h23c38.57 0 59.76-18.78 76.78-33.87 17.65-15.65 32.9-29.16 73.52-29.16a116 116 0 0 1 18.5 1.48 138.5 138.5 0 0 0 7.79-27.16c0-.15.06-.31.08-.47a144 144 0 0 0-26.37-2.41c-93.33 0-88.48 63-150.3 63h-23c-42.42 0-70.3-30.3-70.3-69.09v-31.47c0-38.79 27.88-69.09 70.3-69.09h23c61.82 0 57 63 150.3 63a143.3 143.3 0 0 0 26.37-2.42c0-.14 0-.29-.07-.44a139.4 139.4 0 0 0-7.8-27.16" class="cls-3"/></g></g></g></svg>
|
||||
|
After Width: | Height: | Size: 3.6 KiB |
Reference in New Issue
Block a user