> 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: Add a Custom Action ## Article: Add a Custom Action ## Article Link: https://dev.wix.com/docs/develop-websites-sdk/code-your-site/build-a-custom-backend/automations/add-a-custom-action.md ## Article Content: # Add a Custom Action Custom actions allow you to write custom code that executes when an automation is triggered. The Automations Actions service plugin lets you develop these [custom actions](https://dev.wix.com/docs/develop-websites-sdk/code-your-site/build-a-custom-backend/automations/about-custom-actions.md) directly in your site's dashboard. To add a custom action, you first need to create an automation and add a trigger: 1. Go to the [Automations](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2Ftriggers) page in your site's dashboard. 2. Click **+ Create Automation**, then **Start from Scratch** to open the automation builder. 3. Select and configure a [trigger](https://support.wix.com/en/article/wix-automations-creating-an-automation-with-the-new-builder#step-2-choose-a-trigger). 4. Click the **+** beneath the trigger to add a step and then click **Action**. In the menu on the left, select **Run Velo code**. ![Run velo code action](https://wixmp-833713b177cebf373f611808.wixmp.com/images/34472349eca2250ac5c157eaf040f2c5.png) 5. Click **Start Coding** to add your code. You'll be prompted to create a new code file. ![Start coding](https://wixmp-833713b177cebf373f611808.wixmp.com/images/ebb182e0763598c9a44bfb79d20a5e04.png) 6. Give the file a name and click **Create & Start Coding**. Note that you can't rename the file once it's created. ![Name file and start coding](https://wixmp-833713b177cebf373f611808.wixmp.com/images/05a191f115d4928877886b5c531708e0.png) You should now see something like this: ![Write action code](https://wixmp-833713b177cebf373f611808.wixmp.com/images/b4f70970e7d0a5e7cc5e47a8b9415a06.png) The **Write Velo code** modal contains 2 tabs. The first is the `.js` file where you write your code. The second tab appears under **Payload view** and lets you view the expected structure of the trigger payload. Write your code in the inside the [`invoke()`](https://dev.wix.com/docs/velo/events-service-plugins/automations/service-plugins/automations-actions/invoke.md) method. Make sure the return statement remains empty. 7. When you finish writing your code, click **Save**. After you set up and code your custom action, you can activate the automation immediately. However, we recommend testing the action code first. 8. To test your code, follow the instructions under **Run your code to test this action**. Then click **Run Code**. ![Test your action code](https://wixmp-833713b177cebf373f611808.wixmp.com/images/e0961f5637cd9a5047dfc671fc8021b0.png) Wix provides sample data that matches the structure of your trigger response. You can edit any of the fields in the sample response to test your action. >**Note:** When you test the action, the code runs on your live site and may cause changes on your site or dashaboard. Testing runs your code live on a site and may change a site or dashboard. 9. Once you test your code and are sure your action works. Click **Apply**, then click **Activate**. ## Edit your custom action To edit your action code, [edit your automation](https://support.wix.com/en/article/the-new-automation-builder-managing-your-automations#editing-duplicating-or-renaming-an-automation) and select the **Run Velo code** action. Then click **Edit Code** and make your changes. Make sure to save a re-test your code. Click **Apply**, then click **Publish Changes**. ## See also - [About Custom Actions](https://dev.wix.com/docs/develop-websites-sdk/code-your-site/build-a-custom-backend/automations/about-custom-actions.md) - [Automations Actions service plugin](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)