# Wix Automations: Using Custom Code in an Automation

Source: https://support.wix.com/en/article/wix-automations-using-custom-code-in-an-automation (updated 2026-06-15)
Related: Wix developer documentation, https://dev.wix.com/docs/llms.txt; Help Center index, https://support.wix.com/en/llms.txt

> We recommend only using custom code in an automation if you have prior technical knowledge and experience working with coding.

Enhance your automation using your own code using the **Run Velo Code** action. With this automation action and the Velo APIs, you can customize your site or business in any way you like, for example, by updating your CMS, formatting data, or connecting to third-party applications. Write your code, test it, and then activate the automation.

> **Before you begin:**
>
> * In order to use the **Run Velo Code** action, you must first [enable coding on your site](https://dev.wix.com/docs/develop-websites/articles/getting-started/quick-start#step-1--enable-coding).
> * A service plugin can't be added when using Git Integration and Wix CLI.
> * In order for the code to run, you must have a published site. Be sure to have the proper permission to publish.

---

## Creating an automation with the Run Velo Code action

1. [Go to Automations](https://www.wix.com/my-account/site-selector/?buttonText=Open%20Wix%20Automations&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https://www.wix.com/dashboard/{{metaSiteId}}/triggers/) in your site's dashboard.
2. Click **+ Create Automation** in the top right corner.
3. Click **+ Start from Scratch**.
4. Click the title to give your automation a name.
5. Select a trigger for your automation.
6. Click **+** to add a step.
7. Click **Action**.
8. Click **Run Velo code** on the left.
9. Click **Start Coding**.
10. Give a name to the JS file and click **Create & Start Coding**.
11. Write your code in the window that opens.  
**Notes:** Lines 2 - 6 in the default code support the [autocompletion](https://en.wikipedia.org/wiki/Autocompletion) system. Make sure you keep them in your code file. Additionally, use the "Invoke" function to implement your action logic.
12. Click **Save** for your code to integrate your custom logic in this automation.
13. (Optional) Before activating your automation, run your code to test it and make sure it gives the results you expect. Before you start your test:  
   * Define the **sample data** that will run in the test.  
   * Open the **site logs** to monitor the result.
14. When ready, click **Activate** at the top right.

> **Important:** Running your code to test means it's running live, so it might make changes within your site and/or dashboard.

![screenshot of an automation flow with Run Velo Code action and side panel open to configure it.](https://d2x3xhvgiqkx42.cloudfront.net/12345678-1234-1234-1234-1234567890ab/1d4b9a27-f0a5-449a-99cc-188228a9c725/2024/12/30/caca59b9-a621-4719-8d1b-eb23ce796007/4505b5cd-fe1e-496d-b088-b5b720b302e5.png)

---

## FAQs

**Can I use data from the trigger in my custom action?**

Yes, you can use the data from the trigger or other parts of the automationby using it in the code:

  
![Screenshot of the payload](https://d2x3xhvgiqkx42.cloudfront.net/12345678-1234-1234-1234-1234567890ab/1d4b9a27-f0a5-449a-99cc-188228a9c725/2025/02/12/475587e7-f14e-4081-85d9-c9b0953ba838/e55b1e54-f951-4b0f-9a93-b1c69a4d8597.png)

**Where can I find the specifications for the payload?**

You can view the payload specification by clicking the **Payload View** tab in the pop-up screen when writing Velo code.

![Screenshot of the payload view tab](https://d2x3xhvgiqkx42.cloudfront.net/12345678-1234-1234-1234-1234567890ab/1d4b9a27-f0a5-449a-99cc-188228a9c725/2025/03/04/ac645e6f-6fb3-4b81-b67f-bf692dee759f/6f335c45-5b46-45fd-af09-da5c375faf5e.png)

**Can I edit the Run Velo Code action in any code environment?**

Yes, you can edit the code in 3 different environments: 

* In the action configuration itself of the automation builder (recommended).
* In the backend service plugin file in the site code editor.
* In the Wix IDE (for Wix Studio only).

  
 Learn more about [custom extensions](https://www.wix.com/velo/reference/spis/getting-started).

**Why do I get an error when creating a .js file with Run Velo Code on a GitHub-connected site?**

Creating a new .js file is not supported for Git-managed code. The file won't be added to your GitHub repository and you'll most likely see the error 'We could not load Velo code'.

![](https://d2x3xhvgiqkx42.cloudfront.net/12345678-1234-1234-1234-1234567890ab/978d874e-0e33-4cf0-ac42-b27ede6135db/2026/05/18/9be02793-0f77-4f6d-a389-7c2c4ffb6d34/40662d23-7568-4462-98ef-7f39395b98fd.png) 

 Even though a backend file may appear in your editor, it's best to manage all your code via GitHub. We recommend that:

* You create backend files and functions directly in your GitHub repository (or in the Velo editor in a way that it's synced with GitHub), not via automations on your site.
* In the **Run Velo Code** action, you select an existing backend function instead of creating a new file from the automations interface.

**What should I be aware of when connecting to a third-party provider using SPIs?**

If you connect to a third-party provider using SPIs, you agree to the [Wix.com Terms of Use](https://www.wix.com/about/terms-of-use). Wix is not responsible for your use of such a third-party provider, and any liability resulting from such use will be your responsibility.

**Where can I find help implementing an SPI?**

If you need help implementing SPI, there are [professionals](https://www.wix.com/marketplace) who can help you.
