> 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 an Action to Your App ## Article: Add an Action to Your App ## Article Link: https://dev.wix.com/docs/api-reference/business-management/automations/actions/add-an-action-to-your-app.md ## Article Content: # Add an Action to your App As a developer, you can provide actions to Wix users when they install your app. Follow this article to learn how to set up an action in the [app dashboard](https://dev.wix.com/apps/my-apps?viewId=active-apps-view). ## Before you begin You need to have an app already created in the [Custom Apps page](https://dev.wix.com/docs/build-apps/get-started/tutorials/tutorial-set-up-an-app-with-the-app-dashboard.md). ## Step 1 | Set up the action Start by creating an action for your app in the Dev Center. 1. From your app’s dashboard, go to the [**Automations**](https://dev.wix.com/app-selector?title=Select+an+App\&primaryButtonText=Select+Site\&actionUrl=https%3A%2F%2Fdev.wix.com%2Fapps%2F%7BappId%7D%2Fautomations-dev-center) tab. ![Dev Center Automations tab](https://wixmp-833713b177cebf373f611808.wixmp.com/images/c1a2898d7e8757c775bb25bcf2b4edd4.png) 2. At the top of the page, click **Create New > Action**. This opens the **New Action** page. On the left of the page is some basic setup required to publish your action. On the right, you’ll see an action preview section. This shows a preview of the options that will appear on a user’s site dashboard when they set up your action. The preview updates automatically as you configure your action. 3. In the **Action details** section, give your action a name. The name is displayed to users when they go to select an action for their automation. It’s important to give your action a clear name, so that users understand what it does. To keep your action name user-friendly and consistent with other actions, we recommend following these best practices: * Use active voice. * Keep the name singular. * Use sentence case, and don't end with a period. * Make sure it can’t be confused with another action. For example, the action name “Send an email” is already in use, so name your action instead something like “Send a confirmation email”. Some examples of good action names are: * **Send a birthday card** * **Create appointment for guest** * **Request tour booking** 4. Give your action a key. Wix uses the action key when it makes calls to your URI. It is not visible to users. Once you save your action, you can’t edit the action key. Wix suggests a default key based on your app’s name and the action name. The default key takes the following format: <*app\_name*>-<*action\_name*>. We recommend sticking with this format, but you can edit the action key as long as it meets the following standards: * Starts with a letter or number. * Contains only lowercase letters, numbers, hyphens, and underscores. * Isn't the same as another action key in your app. 5. Optionally, add a description of your action that explains what it does. This is displayed to users after they select your action in their dashboard. ## Step 2 | Choose service plugin endpoints to implement You’re required to implement the [Invoke](https://dev.wix.com/docs/api-reference/business-management/automations/actions/action-provider-service-plugin/invoke.md) endpoint in your server code. Invoke executes your action logic. In addition to Invoke, you have the option to implement other [service plugin](https://dev.wix.com/docs/develop-websites/articles/coding-with-velo/integrations/service-plugins-formerly-spis/custom-app-extensions-using-spis.md) endpoints that perform logic on your app’s end when Wix calls them. Choose the endpoints you want to implement in the **Service plugin endpoints** section of the **New Action** page: ![Action service plugin options](https://wixmp-833713b177cebf373f611808.wixmp.com/images/25f20b6295895d0a5abfb393330056ef.png) 1. Whether or not you implement optional service plugin endpoints, you’re required to provide a valid service plugin URI, so that Wix knows where to call Invoke. Wix looks for the Invoke endpoint under the relative route `/v1/invoke`. Implement any additional service plugin endpoints in a similar manner. For example, implement [Validate Configuration](https://dev.wix.com/docs/api-reference/business-management/automations/actions/action-provider-service-plugin/validate-configuration.md) under `/v1/validate-configuration`. 2. Select whichever endpoints you plan to implement. ## Step 3 | Configure the input schema Create a JSON schema that [defines the inputs your action can receive](https://dev.wix.com/docs/api-reference/business-management/automations/actions/the-action-input-schema.md) from the user or the trigger payload. 1. In the section labeled **Configure the input schema**, click **Generate from Sample Data**. ![Generate sample data](https://wixmp-833713b177cebf373f611808.wixmp.com/images/ff2b8bbf7aa34c7baf0c1f76536838b0.png) 2. In the modal that opens, enter sample data that you expect to be passed to your action. When you have entered all your data, click **Convert to Schema**. ![Convert sample to schema](https://wixmp-833713b177cebf373f611808.wixmp.com/images/6a3fb7dcf6acd70f2e280182de16773a.png) Wix generates an input schema for you from the data you enter. ![Example schema](https://wixmp-833713b177cebf373f611808.wixmp.com/images/33189424df5920d810e89796b9d1a5a2.png) 3. Review the generated schema and add or edit any fields you need to. By default, all the fields you add in the generator are added to the `required` array. Manually remove any fields that you don’t want marked as required in the action configuration UI. Use the **Format Schema** button at the bottom of the section to format the JSON if needed. 4. Notice that a field appears in the action preview every time you add a property to the input schema `properties` object. You can interact directly with the action preview and enter values into the fields to test it. Test values that you enter in the preview aren’t saved and don’t affect the UI that Wix users see on their site. ![action preview](https://wixmp-833713b177cebf373f611808.wixmp.com/images/f28a74ae497828f3bfa1824f9c8d4612.gif) 5. If you want to create extra functionality in your action UI, continue to Step 4 to build the UI schema. Otherwise, click **Save & Close** to save your action, and skip to [Step 6](#step-6--test-your-action-on-a-site) to test the action on a site. ## Step 4 | Configure the UI schema (optional) The [UI schema](https://dev.wix.com/docs/api-reference/business-management/automations/actions/about-actions.md) allows you to do the following: * Extend the functionality of the basic UI generated by the input schema. * Mark fields as dynamic. To create a UI schema: 1. In the section labeled **User Interface**, add a key-value schema. To add extra features to a field in the action configuration UI, add a key to the UI schema that matches the field’s key in the input schema. Create a new object as its value. For example, if you have a number field `age` in your input schema, create a field with a matching key in the UI schema: ```json { "age": {} } ``` Add the properties inside the object value. You can learn more about the properties available to each data type in the [Action UI library](https://www.wix-pages.com/automations-ui-lib/?path=/story/getting-started--about). 2. To make a field [dynamic](https://www.wix-pages.com/automations-ui-lib/?path=/story/dynamic-fields--text-field), use the `dynamicValuesOptions` field, and set `enabled` to true: ```json { "age": { "dynamicValuesOptions": { "enabled": true } } } ``` 3. If you want to define your action's output, continue to Step 5 to create the output schema. Otherwise, click **Save & Close** to save your action and exit, and skip to [Step 6](#step-6--test-your-action-on-a-site) to test the action on a site. ## Step 5 | Configure the output schema (optional) Create a JSON schema that [defines the data your action outputs](https://dev.wix.com/docs/rest/business-management/automations/actions/about-actions.md#the-output-schema). You can skip this step if your action doesn’t output any data. 1. Click the toggle on the section labeled **Configure an output schema** to open it. ![Open the output schema](https://wixmp-833713b177cebf373f611808.wixmp.com/images/9539fc1d3a6cd4aa9417cf6e9bfe3075.png) 2. Click on **Generate from Sample Data**. In the modal that opens, enter sample data that you expect your action to output. When you have entered all your data, click **Convert to Schema**. Wix generates a JSON schema based on the data you entered. ![Output schema](https://wixmp-833713b177cebf373f611808.wixmp.com/images/a9ad9d9031f40b8dfebc666f93c94094.png) 3. Review the generated schema and add or edit fields as needed. Use the **Format Schema** button at the bottom of the section to format your schema nicely. ## Step 6 | Test your action on a site Test your action on a [free development site](https://dev.wix.com/docs/build-apps/launch-your-app/app-distribution/test-your-app/test-your-app-on-a-premium-site.md) to see how the UI appears on a user’s site. 1. On the main [**Automations**](https://dev.wix.com/app-selector?title=Select+an+App\&primaryButtonText=Select+Site\&actionUrl=https%3A%2F%2Fdev.wix.com%2Fapps%2F%7BappId%7D%2Fautomations-dev-center) page in your app, click **Test Your App,** and select **Dashboard**. Select the site you want to test your action on. This takes you to the site’s App Market page. ![Test the app on the dashboard](https://wixmp-833713b177cebf373f611808.wixmp.com/images/de14ad805f1c67bdeae616db50708641.png) 2. Click **Add to Site**. In the window that pops up, click **Agree & Add** to give the app permissions for your site. ![Install app](https://wixmp-833713b177cebf373f611808.wixmp.com/images/f8bae2751ad13c2d8c7d471f11d13e25.png) Once the app is installed successfully, you can close the window and return to the App Market page. 3. On the App Market page, click **Open**. This takes you to your app in the site dashboard. 4. In the dashboard, go to [**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) and click **New Automation** > **Start from Scratch** to open the Automations Builder. In the panel on the left, select any trigger from the options presented. 5. Below the trigger, click the **+** symbol and select **Action**. This opens the action panel on the left. Locate your action in the list. ![Select an action](https://wixmp-833713b177cebf373f611808.wixmp.com/images/924d7a63902d7c703c86db083ef8baa4.png) 6. Select the action to see the UI you created with your input and UI schemas. You can test the UI by entering values into the fields. The fields perform validation and will give you an error if you enter an invalid value. 7. To test the automation further, click **Activate** and try it out on your published site. You’ve now created an action as part of your app.