Important:
This endpoint returns a JSON schema object that's used to dynamically update the fields available to a Wix user when they configure an automation.
Wix calls this endpoint when a user selects an option from an item selection filter configured for a trigger. Wix appends the returned schema to the payload schema you defined for the trigger and makes the fields available to the Wix user's automation.
function getDynamicSchema(
payload: GetDynamicSchemaEnvelope,
): GetDynamicSchemaResponse | Promise<GetDynamicSchemaResponse>;
import { createClient } from '@wix/sdk';
import { triggerProvider } from "@wix/automations/service-plugins";
const wixClient = createClient({
auth: {
appId: <YOUR_APP_ID>,
publicKey: <YOUR_APP_PUBLIC_KEY>
},
modules: { triggerProvider }
});
wixClient.triggerProvider.provideHandlers({
getDynamicSchema: async (payload) => {
const { request, metadata } = payload;
// Use the `request` and `metadata` received from Wix and
// apply custom logic.
return {
// Return your response exactly as documented to integrate with Wix.
// Return value example:
$schema: "https://json-schema.org/draft/2019-09/schema",
type: "object",
title: "Forms dynamic schema example",
default: {},
examples: [
{
email: "email@email.com",
message: "I completed your form."
}
],
properties: {
email: {
$id: "#/properties/formId",
type: "string",
format: "email",
title: "Email",
default: "",
examples: [
"email@email.com"
]
},
message: {
$id: "#/properties/formName",
type: "string",
title: "Message",
default: "",
examples: [
"Hey, nice form!"
]
}
},
required: [
"email",
"message"
],
additionalProperties: false
}
}
});
// Implement a router to process all requests
express.post('/plugins-and-webhooks/*', (req, res) => {
wixClient.process(req);
});