> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt ## Resource: About Custom Actions ## Article: About Custom Actions ## Article Link: https://dev.wix.com/docs/develop-websites-sdk/code-your-site/build-a-custom-backend/automations/about-custom-actions.md ## Article Content: # About Custom Actions When you create a new [automation](https://support.wix.com/en/article/wix-automations-about-the-new-automations-builder) on a site, you can select from various actions to execute after your automation is triggered. Available actions depend on the apps installed on your site and the selected trigger. If the available actions don't meet your needs, you can create a custom action with functionality tailored to your site. Custom actions are site-specific and independent of any app. You create custom actions in your site's dashboard using the automation builder. To customize the action's behavior, you use the [Automations Actions service plugin](https://dev.wix.com/docs/velo/events-service-plugins/automations/service-plugins/automations-actions/introduction.md), which allows you to add your own code directly in the automation builder. You can use custom actions to: - Create custom email notifications for specific events. - Trigger 3rd-party APIs when a subscriber signs up on your site. - Log specific actions into a custom database for business analysis. > **Note:** Custom actions currently require the use of a Velo service plugin API. While you can use the JavaScript SDK alongside the service plugin, the service plugin itself is implemented using Velo APIs and conventions. ## Supported IDEs You can implement custom actions using: - The [editor](https://dev.wix.com/docs/develop-websites-sdk/code-your-site/developer-environments/editors/wix-studio-working-with-the-code-panel.md) (Wix Studio and Wix Editor) - The [Wix IDE](https://dev.wix.com/docs/develop-websites-sdk/code-your-site/developer-environments/ides/wix-studio-about-the-wix-ide.md) (Wix Studio) ## Custom action code When you create a custom action, Wix creates a `.js` file for you to write your code. You then edit this file in a modal inside the builder. Wix automatically populates the `.js` file with the following code: ```js /** * Autocomplete function declaration, do not delete * @param {import('./__schema__.js').Payload} options */ export const invoke = async ({payload}) => { return {} // The function must return an empty object, do not delete }; ``` You must write all your code inside the [`invoke()`](https://dev.wix.com/docs/velo/events-service-plugins/automations/service-plugins/automations-actions/invoke.md) method. Wix calls this method each time the automation is triggered, and runs the code inside. It expects an empty object in return, so make sure to leave the return statement as it appears. To write your action code, use the JavaScript SDK APIs just like you would in your site's public or backend files. When you create a custom action for the first time, Wix automatically adds the Automations Actions service plugin to your site's backend code. For every custom action you create, Wix also adds a folder containing a copy of the `.js` file from the builder.
__Important:__ You can view your custom action code in the backend files of your site. However, all code must be added and updated directly in the automations builder. Any changes you make in the backend files aren't reflected when the automation runs.
Working directly in the automation builder allows you to: - Easily verify you are working with the correct trigger. - View the full trigger payload. - Edit sample data provided by Wix and test your code with it. ## Payload data Depending on the trigger you select, your action expects to receive a payload when the automation is triggered. You can view the payload structure under the **Payload view** tab while writing your code in the builder. The structure is read-only. You can access payload data in your code with dot notation. For example: ```js /** * Autocomplete function declaration, do not delete * @param {import('./__schema__.js').Payload} options */ export const invoke = async ({payload}) => { console.log(payload.status) return {} // The function must return an empty object, do not delete }; ``` ## Editing the automation To edit your action code, return to the automation in the builder and make your changes directly in the custom action modal. The code file you create for your custom action is associated with the original trigger you selected. Editing the trigger configuration doesn't affect the custom action. However, if you change the trigger, a new code file is created and you'll have to write new code. The initial file you create is still saved, and if you restore the trigger it's associated with, you'll be able to access it again in the automation. ## See also - [Create a Custom Action](https://dev.wix.com/docs/develop-websites-sdk/code-your-site/build-a-custom-backend/automations/add-a-custom-action.md) - [Automations Actions API Reference](https://dev.wix.com/docs/velo/events-service-plugins/automations/service-plugins/automations-actions/introduction.md) - [About Automations](https://dev.wix.com/docs/develop-websites-sdk/code-your-site/build-a-custom-backend/automations/about-automations.md)