Tutorial: Set Up an App With the Wix Developers Center

This tutorial shows you how to set up a new Wix app using the Wix Developers Center. 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 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 app's dashboard page 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 Wix Developers Center.

The end result will look like this:

We'll take the following steps to implement the Product of the Day app:

  1. Clone the app repository.
  2. Create an app in the Wix Developers Center.
  3. Configure permissions for your app.
  4. Set up the app's dashboard page.
  5. Set up the app's backend.
  6. Test the app out locally.

Before you begin

Before getting started, make sure that:

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:

Copy
1
git clone https://github.com/wix/wix-developers-example-apps.git

Then navigate to the folder containing the Product of the Day app:

Copy
1
cd wix-developers-example-apps/product-of-the-day

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 Wix Developers Center

The Wix Developers Center 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.

  1. Go to the Wix Developers Center and sign in.

  2. 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 page in the Wix Developer Center:

  3. 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:

  1. Go to the Wix REST API reference documentation.

  2. 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.
  3. In each endpoint reference, look for Permission Scopes:

    The Product of the Day app requires the following permission scopes:

    EndpointRequired permissions
    Query ProductsRead Products
    Create a CouponManage Coupons (with the identifier SCOPE.DC-COUPONS.MANAGE-COUPONS)
    Send MessageManage Inbox Messages

Add permissions

To add permissions for the app to request upon installation:

  1. Go to your app's page in the Wix Developers Center.
  2. In the left sidebar, click Permissions.
  3. For each permission scope:
    1. Click Add Permissions.
    2. Enter the permission scope's name in the Search by name or ID field.
    3. Check the permission scope's checkbox under Choose Permission Scopes.
    4. 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:

  1. Navigate to the client folder:

    Copy
    1
    cd client
  2. Install the dependencies:

    Copy
    1
    npm install
  3. Start the local server for the dashboard page:

    Copy
    1
    npm run start:secure

    This 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:

  1. Go to your app's page in the Wix Developers Center.

  2. In the left sidebar, click Extensions.

  3. Click Create Extension.

  4. Check the Dashboard checkbox.

  5. In the Dashboard Page card, click Create.

  6. Under Page info, in the iFrame URL field, enter the address for your local dashboard page server: https://localhost:3000/.

  7. Under Sidebar configuration, in the Page name field, enter a name for your dashboard page. This name is shown in the dashboard sidebar menu.

  8. 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:

  1. In the product-of-the-day/server folder, create a file named .env with the following placeholder values:

    Copy
    1
    APP_ID=<APP_ID>
    2
    APP_SECRET=<APP_SECRET KEY>
    3
    WEBHOOK_PUBLIC_KEY="<APP_WEBHOOK_PUBLIC_KEY>"

    Note: Only the webhook public key value needs to be enclosed in quotes.

  2. Go to your app's page in the Wix Developers Center.

  3. In the left sidebar, click OAuth.

  4. 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:

  1. Go to your app's page in the Wix Developers Center.

  2. In the left sidebar, click Webhooks.

  3. Click Add Webhook.

  4. Under API Category, select Inbox.

  5. Check the box next to Message Sent To Business.

  6. 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.

  7. Click Save. This takes you back to the Webhooks page.

  8. Under Public key, click Open.

  9. Click Copy Key.

  10. In your .env file, replace <APP_WEBHOOK_PUBLIC_KEY> with the key value:

    Copy
    1
    WEBHOOK_PUBLIC_KEY="<APP_WEBHOOK_PUBLIC_KEY>"

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:

  1. Open a new terminal window, and navigate to product-of-the-day/server:

    Copy
    1
    cd product-of-the-day/server
  2. Install the app's dependencies:

    Copy
    1
    npm install
  3. Start the local app server:

    Copy
    1
    npm run start

    This 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.
  4. Copy the RedirectUrl, AppUrl, and Message 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:

  1. Go to your app's page in the Wix Developers Center.
  2. In the left sidebar, click OAuth.
  3. 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.
  4. Click Save.

Configure the webhook

To make sure your app receives the webhook:

  1. In the left sidebar, click Webhooks.
  2. In the Webhook List, next to the Message Sent to Business webhook, click the ellipsis . Then, click Edit.
  3. In the Callback URL field, enter the Message received webhook URL from the previous step.
  4. Click Save.

Your app is now properly configured in the Wix Developers Center, 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:

  1. In your app's page in the Wix Developers Center, click Test Your App in the top right, then click Create Development Site.

  2. In the list of business solutions to install on the development site, click Wix Stores, then click Create Site.

  3. Go to Wix.com.

  4. In your Sites page, find the development site you just created. The automatically generated name begins with Dev Site.

  5. Hover over the development site and click Select & Edit Site. This opens the site's dashboard.

  6. Click Design Site. This opens the site's editor.

  7. Add a product page to the site:

    1. In the left sidebar, click Pages & Menu .
    2. In the Stores Pages tab, select Product Page.
    3. Click Add Shop Page.
  8. 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:

  1. Return to your app's page in the Wix Developers Center.
  2. Click Test Your App, then click App Market Website. This takes you to a page for your app in the Wix App Market.
  3. Click Add to Site.
  4. Next to the development site you just created, click Select.
  5. 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:

  1. 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.

  2. Click Choose Product.

    This opens a menu to select a product.

  3. 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.

  4. 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.

  1. Open your development site's editor, hover over Publish in the top right, then click View Site to open your live site.

  2. In your live site, click the chat icon on the bottom right to open the chat widget.

  3. In the chat widget, type any text. For example, "Hello".

  4. After a few moments, you'll receive a response in the chat widget, offering you a discount on the product of the day:

  5. 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.

  6. In the product page, click Add to Cart. Then, to go to the cart page, click View Cart.

  7. 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:

Copy
1
const dayjs = require('dayjs'); // ADDED: Import the Day.js library for date formatting.
2
const _ = require('lodash'); // ADDED: Import the Lodash library for working with objects.
3
4
class ProductOfTheDayService {
5
6
// ...
7
8
async sendCouponOfTheDay(instanceId, participantId) {
9
const today = dayjs().format('DD/MM/YYYY'); // ADDED: Store the current date.
10
const productOfTheDayData = await this.productOfTheDayDao.getBy(instanceId)
11
const conversationResult = await this.wixInboxApis.getConversation(instanceId, participantId)
12
const conversationId = conversationResult?.conversation?.id
13
const coupon = await this.couponsDao.getBy(conversationId, today); // ADDED: Retrieve existing coupon for this conversation with the current date, if there is one.
14
if(_.isEmpty(coupon)){ // ADDED: Send a coupon only if no existing coupon was retrieved for this conversation with the current date.
15
const query = {"filter":`{\"id\": {\"$eq\": \"${productOfTheDayData.productId}\"}}`}
16
const [productData, couponData] = await Promise.all([
17
this.storesApis.queryProducts(instanceId, query),
18
this.couponsApis.createCoupon(instanceId, productOfTheDayData.productId,
19
productOfTheDayData.discountPercentage)
20
])
21
this.couponsDao.save(instanceId, conversationId, today, couponData); // ADDED: Save the coupon in the coupon database.
22
const message = this.generateCouponMessage(conversationId, couponData, productData?.products, productOfTheDayData.discountPercentage)
23
console.log('sending coupon...');
24
return this.wixInboxApis.sendMessage(instanceId, message)
25
} // ADDED
26
}
27
28
// ...
29
30
31
}
32
33
module.exports = {
34
ProductOfTheDayService
35
}

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:

Was this helpful?
Yes
No