Install the Amazon Sales Channel app
Review the Prerequisites before you attempt to install the Amazon Sales Channel app.
Clone application source code
Clone the amazon-sales-channel-app-builder repo to your working directory:
Copied to your clipboardgit clone git@github.com:adobe/amazon-sales-channel-app-builder.git <custom-directory>
Setup project dependencies
Change directories to the cloned repo and run the following commands:
Download dependencies and prepare the project.
Copied to your clipboardnpm installBuild the project.
Copied to your clipboardnpm run buildThe command cleans, compiles, and runs the
aio app buildcommand.
Configure your application
Add services
In your App Builder project:
In your workspace, click the Add service pop-up menu and select API.
On the Add an API page, filter on Adobe Services and select I/O Management API. Then click Next.
On the Configure API page, select the Service Account (JWT) option and click Save configured API.
Select Generate key pair.
Click Save configured API.
Repeat this process and create an
Adobe I/O Events for Adobe Commerceservice.
Set up your environment
From the root of the cloned repo, make a copy of the
.env.distfile.Copied to your clipboardcp .env.dist .envRun the
aio app usecommand to define your workspace.Copied to your clipboardaio app useThe following menu displays in the terminal:
Copied to your clipboardYou are currently in:1. Org: <no org selected>2. Project: <no project selected>3. Workspace: <no workspace selected>? Switch to a new Adobe Developer Console configuration: A. Use the global Org / Project / Workspace configuration:1. Org: <your org>2. Project: <your project>3. Workspace: <your workspace>? The file /<project_path>/.env already exists: Merge✔ Successfully imported configuration for:1. Org: <your org>2. Project: <your project>3. Workspace: <your workspace>
At this point, the .env and .aio files should be populated. You can remove any leftover property, such as AIO_ims_contexts_<App_Builder_Reference> from the .env file.
Test your configuration by running npm run deploy to deploy your application into App Builder.
Add your encryption keys
The credentials stored in the application are encrypted using an AES-256 algorithm. You must generate a set of custom encryption keys and provide them to the .env file to secure authentication data.
| Key | Description | 
|---|---|
ENCRYPTION_KEY  | 32 character long encryption key  | 
ENCRYPTION_IV  | Initialization vector  | 
Add your Adobe Commerce credentials
The application needs to connect to an Adobe Commerce instance to retrieve the product catalog updates and to ingest Amazon orders. Define the following variables inside the .env file:
| Key | Description | 
|---|---|
ADOBE_COMMERCE_BASE_URL  | The base URL of your Adobe Commerce instance  | 
ADOBE_COMMERCE_CONSUMER_KEY  | The consumer key of the integration created in Adobe Commerce  | 
ADOBE_COMMERCE_CONSUMER_SECRET  | The consumer secret of the integration created in Adobe Commerce  | 
ADOBE_COMMERCE_ACCESS_TOKEN  | The access token of the integration created in Adobe Commerce  | 
ADOBE_COMMERCE_ACCESS_TOKEN_SECRET  | The access token secret of the integration created in Adobe Commerce  | 
Configure Required Events in Commerce
Amazon Sales Channel on App Builder requires using I/O Events to automatically detect and respond to changes in your Commerce product catalog. The observer.catalog_product_save_after event is emitted when products are updated, such as when a product's name or price changes. You must configure this event and the fields that the event payload contains as part of setup. This event will be sent from Commerce to your App Builder application. By subscribing to the event published by Commerce, Amazon Sales Channel knows when your Commerce product catalog changes and can automatically make the relevant updates to your Amazon Marketplace product listings.
Create the etc/io_events.xml file in the root directory of your module, if it has not already been created. Register the observer.catalog_product_save_after event using the following code. If this event is already registered, ensure that it has all of the required fields.
Copied to your clipboard<event name="catalog_product_save_after"><fields><field name="sku" /><field name="price" /><field name="stock_data.qty" /><field name="asin" /><field name="amazon_condition" /><field name="name" /></fields></event>
See I/O Events for Adobe Commerce for more details. Adobe recommends using the io_events.xml method to configure events, but you can also configure events by modifying the app.config file or by using the CLI. The same event and fields are required, regardless of the method implemented.
Subscribe to Adobe Commerce events
Ensure that your Adobe Commerce instance is registered as an event provider as described in Subscribe and register events.
Register the
observer.catalog_product_save_afterevent in your project in developer console.- Add a new service of type 
Event. - Select your event provider.
 - Choose the 
observer.catalog_product_save_afterevent subscription. - Select the JWT credential.
 - Set a name for your event registration.
 - Select your Runtime action, which should be similar to 
amazon-app/__secured_catalog-product-save-after-listener - <your project>-<your workspace>, then save the event. 
- Add a new service of type 
 
At this point, if you go to the Debug tracing area in your new event created inside the developer console, you should be able to see any incoming events from your Adobe Commerce instance.
Local Dev environment
Compile the TypeScript files in the
actions-srcdirectory intoactions.Copied to your clipboardnpm run compileStart your local dev server.
Copied to your clipboardaio app runBy default, the app runs on
localhost:9080. If the port is not available,check the console logs for the updated port.The UI is served locally, but actions are deployed and served from Adobe I/O Runtime. To start a local serverless stack and also run your actions locally, use the
aio app run --localoption.
Admin UI SDK
The Amazon Sales Channel on App Builder is securely injected into the Commerce Admin experience using the Admin UI SDK. This UI extensibility functionality enables merchant administrators to use a seamless app UI experience in the Commerce Admin. This sample app is just one example of how App Builder integrations can extend Commerce Admin with their own apps' UI.
Admin configuration and testing describes how to test functionality locally. For testing in production, push the Amazon Sales Channel app to production and have an administrator approve the app.
Test the app
Use the following commands to run unit tests:
Copied to your clipboardaio app test #runs UI and actions tests
Copied to your clipboardaio app test --e2e #runs end-to-end tests
Adding additional action dependencies
You have two options to resolve your action's dependencies:
Packaged action file: Add your actions dependencies to the root
package.jsonand install them usingnpm install. Then set thefunctionfield inext.config.yamlto point to the entry file of your action folder.webpackis used to package your code and dependencies into a single minifiedjsfile. The action will then be deployed as a single file. Use this method if you want to reduce the size of your actions.Zipped action folder: In the folder containing the action code, add a
package.jsonwith the action dependencies. Then set thefunctionfield inext.config.yamlto point to the folder of that action. The required dependencies are installed within that directory. In addition, the process zips the folder before deploying it as a zipped action. Use this method if you want to keep your action's dependencies separated.
Debugging in VS Code
Both UI and actions can be debugged while your local server is running. To start debugging, open the VS Code debugger and select the WebAndActions debugging configuration. Other debug configurations are also available for the UI and each separate action.
Deploy the app
Run the following command to compile, build, and deploy all TypeScript actions on Runtime and static files to CDN.
Copied to your clipboardnpm run deploy
The aio app undeploy command undeploys the app.
Typescript support for UI
Use the .tsx extension to designate TypeScript for React components. Also, create a tsconfig.json file that defines the following configuration:
Copied to your clipboard{"compilerOptions": {"jsx": "react"}}