Tutorial | Set Up an App with the App Dashboard
This tutorial shows you how to set up a new Wix app using the app dashboard. The tutorial shows you how to create, configure, and test an externally hosted "Product of the Day" app that can be installed on a Wix site. The app lets site admins offer a daily discount on a product they choose.
Upon downloading the app, the site gains access to the following features:
- In the site dashboard: A dashboard page where a site admin can choose a product from their catalog to discount.
- In the site: An automated chat message offering site visitors a discount coupon for the selected product.
The dashboard page extension is built with React and the server with Express.js. We provide all the code you need for this app in the example apps GitHub repository. Regardless of the technologies you use to build your app, you can take similar steps to integrate it with the app dashboard.
The end result will look like this:
We'll take the following steps to implement the Product of the Day app:
- Clone the app repository.
- Create an app from the Custom Apps page in your Wix Studio workspace.
- Configure permissions for your app.
- Set up the dashboard page extension.
- Set up the app's backend.
- Test the app out locally.
Before you begin
Before getting started, make sure that:
- You have Node.js (v16.4 or higher).
- You're logged into your Wix Studio account. If you don't already have one, sign up for a Wix Studio account.
Step 1 | Clone the app repository
This tutorial uses a pre-built app we've saved in the example apps GitHub repository.
To clone the repository to your computer, open the terminal and run the following command from the folder you want to clone the repository into:
1
Then navigate to the folder containing the Product of the Day app:
1
Within this folder you can find both the backend app server (in the server
folder) and the frontend dashboard component (in the client
folder).
Step 2 | Create an app in the Custom Apps page of your Wix Studio workspace
The Custom Apps page in your Wix Studio workspace is the place for managing Wix apps you develop. Follow these steps to create a Wix app that we'll connect to the external servers.
-
Go to Wix Studio and sign in.
-
If this is your first Wix app, click Start Building. If you already have an app, click Create New App in the top-right corner. This opens your new app's dashboard:
-
Click the default name generated for your app, and enter a new one, such as "Product of the Day".
Step 3 | Configure permissions for your app
This app uses Wix REST APIs to access and manage Wix site data, requiring specific permissions to access each endpoint. To ensure functionality, your app needs these permissions from any site using it. This section guides you through setting up your app to request these permissions upon installation.
Find required permissions
To find the permissions that your app requires:
-
Go to the Wix REST API reference documentation.
-
Find the specific endpoints that your app calls. The Product of the Day app calls the following endpoints:
- Query Products: To retrieve information about products in the site's catalog.
- Create a Coupon: To generate a discount coupon for the product the site owner chooses.
- Send Message: To send site visitors a message with the coupon in the Wix Chat widget.
-
In each endpoint reference, look for Permission Scopes:
The Product of the Day app requires the following permission scopes:
Endpoint Required permissions Query Products Read Products Create a Coupon Manage Coupons (with the identifier SCOPE.DC-COUPONS.MANAGE-COUPONS
)Send Message Manage Inbox Messages
Add permissions
To add permissions for the app to request upon installation:
- Go to Permissions in your app's dashboard.
- For each permission scope:
- In the left sidebar, click Add Permissions.
- Enter the permission scope's name in the Search by name or ID field.
- Check the permission scope's checkbox under Choose Permission Scopes.
- Click Save.
Now, when a site owner installs the app, Wix prompts them to grant the necessary permissions.
Step 4 | Set up the dashboard page
Every Wix site has a dashboard where site admins manage their site and business. Our app integrates with this dashboard by adding a new page where site admins can select a product of the day and apply discounts. The dashboard page is built with React. This section guides you through adding the dashboard page to your app.
Run a local server
Our app includes two servers: one for the dashboard page UI (in the client
folder) and one for the app's backend business logic (in the server
folder).
To run the local development server for the dashboard page UI:
-
Navigate to the
client
folder:Copy1 -
Install the dependencies:
Copy1 -
Start the local server for the dashboard page:
Copy1This runs the local dashboard page server and opens your browser to
https://localhost:3000
.Note: If you encounter a security warning, click Advanced and then Proceed to localhost (unsafe).
Now, you can see the dashboard component open in your browser:
Note: Make sure to keep the local dashboard page server running for the remainder of this tutorial.
Add a dashboard page
To set up your app to include the dashboard page:
-
In the left sidebar, click Extensions.
-
Click Create Extension.
-
Check the Dashboard checkbox.
-
In the Dashboard Page card, click Create.
-
Under Page info, in the iFrame URL field, enter the address for your local dashboard page server:
https://localhost:3000/
. -
Under Sidebar configuration, in the Page name field, enter a name for your dashboard page. This name is shown in the dashboard sidebar menu.
-
Click Save.
Your app is set to add a dashboard page upon installation on a site and load it from the specified URL.
Step 5 | Set up the backend
Our app contains business logic in our backend server. This section guides you through setting up the backend, including authentication for your app.
Configure environment variables
To configure environment variables for authentication:
-
In the
product-of-the-day/server
folder, create a file named.env
with the following placeholder values:Copy1Note: Only the webhook public key value needs to be enclosed in quotes.
-
In the left sidebar, click OAuth.
-
In the
.env
file created in the first step, replace<APP_ID>
with the App ID and<APP_SECRET KEY>
with the App Secret Key.
Add a webhook to your app
Webhooks deliver real-time notifications about events in your app, other apps, or the Wix site. For this app, we'll add the Message Sent To Business webhook, which notifies the app whenever a site visitor sends a message in the Wix Chat widget.
To add a webhook:
-
In the left sidebar, click Webhooks.
-
Click Add Webhook.
-
Under API Category, select Inbox.
-
Check the box next to Message Sent To Business.
-
In the Callback URL field, enter a temporary dummy URL, such as
https://www.test.not
. We'll replace this URL after activating the backend app server. -
Click Save. This takes you back to the Webhooks page.
-
Under Public key, click Open.
-
Click Copy Key.
-
In your
.env
file, replace<APP_WEBHOOK_PUBLIC_KEY>
with the key value:Copy1
Start the backend server
To successfully set up our app, the server for the dashboard page and the backend server need to be running at the same time. To start the backend server:
-
Open a new terminal window, and navigate to
product-of-the-day/server
:Copy1 -
Install the app's dependencies:
Copy1 -
Start the local app server:
Copy1This runs the local app server and displays several important URLs:
RedirectUrl
: Endpoint Wix must redirect to after the user authenticates.AppUrl
: Main entry point for the app's backend functionality.Message received webhook
: Used for receiving callbacks from Wix.
-
Copy the
RedirectUrl
,AppUrl
, andMessage received webhook
and keep them available for the next steps.
Note: Make sure to keep the backend server running for the remainder of this tutorial.
Configure OAuth
Wix uses OAuth 2.0 to authorize apps to access our APIs and receive webhooks. To configure OAuth:
- In the left sidebar, click OAuth.
- Under URLs:
- Enter the
AppUrl
from the previous step into the App URL field. - Enter the
RedirectUrl
from the previous step into the Redirect URL field.
- Enter the
- Click Save.
Configure the webhook
To make sure your app receives the webhook:
- In the left sidebar, click Webhooks.
- In the Webhook List, next to the Message Sent to Business webhook, click the ellipsis
. Then, click Edit.
- In the Callback URL field, enter the
Message received webhook
URL from the previous step. - Click Save.
Your app is now properly configured and ready to test.
Note: Every time you run the Product of the Day app server, it generates new URLs for the app. If you reset the server, repeat this step to configure the updated URLs.
Step 6 | Test the app
Wix provides a free Premium development site so you can easily install your app and see it working. In this step, you'll create a development site, install your app on the site, and try it out.
Set up a development site
To set up a development site:
-
In your app's dashboard, click Test Your App in the top right and then click Create Development Site.
-
In the list of business solutions to install on the development site, click Wix Stores, then click Create Site.
-
Go to Wix.com.
-
In your Sites page, find the development site you just created. The automatically generated name begins with Dev Site.
-
Hover over the development site and click Select & Edit Site. This opens the site's dashboard.
-
Click Design Site. This opens the site's editor.
-
Add a product page to the site:
- In the left sidebar, click Pages & Menu
.
- In the Stores Pages tab, select Product Page.
- Click Add Shop Page.
- In the left sidebar, click Pages & Menu
-
Back in the editor, on the top right, click Publish.
Your development site is now live.
Install the app
To install the app on your development site:
- Return to your app's dashboard.
- Click Test Your App, then click App Market Website. This takes you to a page for your app in the Wix App Market.
- Click Add to Site.
- Next to the development site you just created, click Select.
- Wix now requests the site permissions your app requires. Click Agree & Add.
The Product of the Day app is now installed on your development site.
Try out the dashboard page
To test the app, we'll start by trying out its dashboard page, where we can choose a product of the day and apply a discount:
-
Open the development site's dashboard. Your app now appears in the left dashboard sidebar under the name you entered earlier. Click your app's name in the sidebar.
This opens your app's dashboard page.
-
Click Choose Product.
This opens a menu to select a product.
-
Your development site's catalog is filled with example products with the name "I'm a product". To make these products appear, type "I'm" in the Search by product name field. Then, select a product and click Done.
-
Adjust the percentage Discount to apply to the product, and click Update.
You've now selected a product of the day and applied a discount to it.
Try out the site
Now let's see what the experience is like for a site visitor.
-
Open your development site's editor, hover over Publish in the top right, then click View Site to open your live site.
-
In your live site, click the chat icon
on the bottom right to open the chat widget.
-
In the chat widget, type any text. For example, "Hello".
-
After a few moments, you'll receive a response in the chat widget, offering you a discount on the product of the day:
-
The chat response contains a coupon code and a link. Copy the coupon code, and click the link to go to the product page for the product of the day.
-
In the product page, click Add to Cart. Then, to go to the cart page, click View Cart.
-
Click Enter a promo code, paste the coupon code you copied, and click Apply.
Your Order Summary now incorporates the Product of the Day discount:
Step 7 | Customize the app
The Product of the Day app is now working!
To learn more about how the app works, take a look around the code files in the GitHub repo.
As an exercise to help familiarize yourself with app code a little more, you can add additional functionality to this app.
For example, edit the code so that each site visitor can only receive one discount coupon per day. To do this, edit product-of-the-day/server/src/services/ProductOfTheDayService.js
, and add the lines of code marked as ADDED
below in the comments:
1
With this adjustment, the app now checks whether a discount coupon was already created for the site visitor on the current date. It only sends a coupon if one wasn't already sent.
What next?
Now that you've learned how to set up a pre-made, externally hosted Wix app, you can start thinking about building your own apps. Here are a few resources to get you started:
- Browse the Wix App Market to get inspiration from other apps.
- Learn about self-hosting for Wix apps.
- Get to know our REST API and our JavaScript SDK.
- Read our guidelines for submitting an app to the Wix App Market.