Skip to content

Commit ca7dea1

Browse files
committed
fix(webflow): added form submission trigger and scope
1 parent a3d529d commit ca7dea1

File tree

4 files changed

+43
-19
lines changed

4 files changed

+43
-19
lines changed

apps/sim/lib/auth/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1858,7 +1858,7 @@ export const auth = betterAuth({
18581858
authorizationUrl: 'https://webflow.com/oauth/authorize',
18591859
tokenUrl: 'https://api.webflow.com/oauth/access_token',
18601860
userInfoUrl: 'https://api.webflow.com/v2/token/introspect',
1861-
scopes: ['sites:read', 'sites:write', 'cms:read', 'cms:write'],
1861+
scopes: ['sites:read', 'sites:write', 'cms:read', 'cms:write', 'forms:read'],
18621862
responseType: 'code',
18631863
redirectURI: `${getBaseUrl()}/api/auth/oauth2/callback/webflow`,
18641864
getUserInfo: async (tokens) => {

apps/sim/lib/webhooks/provider-subscriptions.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,7 +1400,7 @@ export async function createWebflowWebhookSubscription(
14001400
): Promise<string | undefined> {
14011401
try {
14021402
const { path, providerConfig } = webhookData
1403-
const { siteId, triggerId, collectionId, formId } = providerConfig || {}
1403+
const { siteId, triggerId, collectionId, formName } = providerConfig || {}
14041404

14051405
if (!siteId) {
14061406
webflowLogger.warn(`[${requestId}] Missing siteId for Webflow webhook creation.`, {
@@ -1456,10 +1456,9 @@ export async function createWebflowWebhookSubscription(
14561456
}
14571457

14581458
// Note: Webflow API only supports 'filter' for form_submission triggers.
1459-
if (formId && webflowTriggerType === 'form_submission') {
1459+
if (formName && webflowTriggerType === 'form_submission') {
14601460
requestBody.filter = {
1461-
resource_type: 'form',
1462-
resource_id: formId,
1461+
name: formName,
14631462
}
14641463
}
14651464

apps/sim/lib/webhooks/utils.server.ts

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -800,15 +800,39 @@ export async function formatWebhookInput(
800800
}
801801

802802
if (foundWebhook.provider === 'webflow') {
803+
const providerConfig = (foundWebhook.providerConfig as Record<string, any>) || {}
804+
const triggerId = providerConfig.triggerId as string | undefined
805+
806+
// Form submission trigger
807+
if (triggerId === 'webflow_form_submission') {
808+
return {
809+
siteId: body?.siteId || '',
810+
formId: body?.formId || '',
811+
name: body?.name || '',
812+
id: body?.id || '',
813+
submittedAt: body?.submittedAt || '',
814+
data: body?.data || {},
815+
schema: body?.schema || {},
816+
formElementId: body?.formElementId || '',
817+
}
818+
}
819+
820+
// Collection item triggers (created, changed, deleted)
821+
// Webflow uses _cid for collection ID and _id for item ID
822+
const { _cid, _id, ...itemFields } = body || {}
803823
return {
804824
siteId: body?.siteId || '',
805-
formId: body?.formId || '',
806-
name: body?.name || '',
807-
id: body?.id || '',
808-
submittedAt: body?.submittedAt || '',
809-
data: body?.data || {},
810-
schema: body?.schema || {},
811-
formElementId: body?.formElementId || '',
825+
collectionId: _cid || body?.collectionId || '',
826+
payload: {
827+
id: _id || '',
828+
cmsLocaleId: itemFields?.cmsLocaleId || '',
829+
lastPublished: itemFields?.lastPublished || itemFields?.['last-published'] || '',
830+
lastUpdated: itemFields?.lastUpdated || itemFields?.['last-updated'] || '',
831+
createdOn: itemFields?.createdOn || itemFields?.['created-on'] || '',
832+
isArchived: itemFields?.isArchived || itemFields?._archived || false,
833+
isDraft: itemFields?.isDraft || itemFields?._draft || false,
834+
fieldData: itemFields,
835+
},
812836
}
813837
}
814838

apps/sim/triggers/webflow/form_submission.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const webflowFormSubmissionTrigger: TriggerConfig = {
2121
type: 'oauth-input',
2222
description: 'This trigger requires webflow credentials to access your account.',
2323
serviceId: 'webflow',
24-
requiredScopes: [],
24+
requiredScopes: ['forms:read'],
2525
required: true,
2626
mode: 'trigger',
2727
condition: {
@@ -96,11 +96,12 @@ export const webflowFormSubmissionTrigger: TriggerConfig = {
9696
dependsOn: ['triggerCredentials'],
9797
},
9898
{
99-
id: 'formId',
100-
title: 'Form ID',
99+
id: 'formName',
100+
title: 'Form Name',
101101
type: 'short-input',
102-
placeholder: 'form-123abc (optional)',
103-
description: 'The ID of the specific form to monitor (optional - leave empty for all forms)',
102+
placeholder: 'Contact Form (optional)',
103+
description:
104+
'The name of the specific form to monitor (optional - leave empty for all forms)',
104105
required: false,
105106
mode: 'trigger',
106107
condition: {
@@ -128,8 +129,8 @@ export const webflowFormSubmissionTrigger: TriggerConfig = {
128129
defaultValue: [
129130
'Connect your Webflow account using the "Select Webflow credential" button above.',
130131
'Select your Webflow site from the dropdown.',
131-
'Optionally enter a Form ID to monitor only a specific form.',
132-
'If no Form ID is provided, the trigger will fire for any form submission on the site.',
132+
'Optionally enter the Form Name to monitor only a specific form.',
133+
'If no Form Name is provided, the trigger will fire for any form submission on the site.',
133134
'The webhook will trigger whenever a form is submitted on the specified site.',
134135
'Form data will be included in the payload with all submitted field values.',
135136
'Make sure your Webflow account has appropriate permissions for the specified site.',

0 commit comments

Comments
 (0)