Build a sample order management system with the Channel App SDK and connect it to Channel Talk.
Check the connection with ping and add an order lookup. Then add the /cancel-order command, cancel an order in a WAM, and notify the manager through a Native Function. Finally, use the lookup in CoS and ALF.
In Channel Works, apps let you connect external services and extend Channel Works features.
For example, your app server can send a team chat message by calling a Native Function through App Store. To add a feature to Channel Works, implement an Extension contract defined by App Store. In this tutorial, you'll use the Command Extension to add /cancel-order to team chat.
Your app server can expose an operation such as looking up an order as an app function. When you run that function in Channel Works, App Store sends an HTTP request to your server. The server you host receives the request and runs the function. You can call it from Developer tools and reuse it in a Command, ALF, or CoS.
You install apps from App Store in channel settings. The App Store server tracks which apps each channel has installed and manages Extension registration.
A WAM (Web App Module) is your app’s web screen inside Channel Works. The Channel Works client loads it directly from your WAM Endpoint.
Call an app function (Channel Works → App Store → app server)
Call a Native Function (App server → App Store → Channel Works)
Load a web screen (Channel Works client → WAM Endpoint)
Familiarity with HTTP requests and responses and TypeScript modules will help. The examples use NestJS decorators and dependency injection to register functions and pass services from providers to constructors. Zod describes function inputs and outputs, and Vite builds the React screen.
For more on how apps work, see App concepts.
Install the latest Node.js 24 LTS patch release. Download Node.js
Install pnpm 10.26 or later to manage dependencies and build the server and WAM packages. Install pnpm
Use a code editor and terminal. Keep the server running in one terminal and enter tutorial commands in another.
Set up the ngrok CLI and an account. Use it to give the local server an HTTPS address that App Store can reach. Install and configure ngrok
Prepare a test channel where you can install apps, and sign in to Channel Developer Portal.
Create an app in Channel Developer Portal and save its keys in server/.env. Use the Channel App SDK to implement ping and start a NestJS server, then call the Function in Developer tools to check the connection.
Open Channel Developer Portal and select Create App in My apps. Enter Order Management, agree to the terms, and confirm.
After creating the app, run these commands to create and enter the tutorial directory.
Open server/.env and add the three entries as shown below. If you use Git, add .env to .gitignore before filling in the values. The portal displays the Secret and Signing Key once, when it issues them. Save each value to server/.env before closing its screen.
Copy the Application ID beneath the app name into APP_ID. App Store uses it to identify the app.
In Auth and Access, issue the Secret and paste it into APP_SECRET. The SDK uses it to obtain an app token from App Store.
In Server Settings, issue the Signing Key and paste it into SIGNING_KEY. The server uses it to verify requests from App Store.
Value | Purpose |
|---|---|
App ID | Public identifier for the app |
App Secret | Secret the SDK uses to obtain tokens from App Store |
Signing Key | Key your server uses to verify signatures on App Store requests |
Why the Signing Key matters. A third party could impersonate App Store if your server skips signature verification. App Store computes an HMAC-SHA256 signature from the Signing Key and the request body, encodes it in Base64, and sends it in x-signature. The SDK's SignatureGuard recalculates the signature using the same key and the original request bytes. Only requests with a matching signature should reach the function.
Create pnpm-workspace.yaml in the project root and add the server package as shown below.
allowBuilds controls which dependencies can run scripts during installation. Setting protobufjs: false skips the install script for this server SDK dependency.
Create server/package.json as shown below with the scripts to build and start the server.
From the project root, run these commands to install the server dependencies. The @channel.io/app-sdk-server package runs on NestJS. This exercise uses @nestjs/platform-express as its HTTP adapter.
Create server/tsconfig.json as shown below. Write the server code in server/src. TypeScript compiles it to JavaScript in server/dist.
Create server/src/ping.function.ts with the code below. ping takes no input and returns pong in message. @Func declares the Function name. @InputSchema and @OutputSchema define its input and output. Use description to say when to call the function and what it returns. ALF and CoS use that description to choose a tool and the input schema to construct its arguments.
Create server/src/index.ts with the code below. This file configures the SDK module and registers PingFunctions in providers. Set the application type to NestExpressApplication to use methods from the Express adapter.
With TypeScript’s NodeNext setting, imports use the filename that Node.js loads at runtime. Import ./ping.function.js, which is what TypeScript emits from ping.function.ts.
App Store sends Function requests to PUT /functions/v1. NestJS preserves the original request body with rawBody: true. The SDK's SignatureGuard uses that body and the Signing Key to verify the signature in x-signature.
For a versioned ping call, App Store sends a request like this to PUT /functions/v1.
The SDK matches method to a registered @Func, passes params to @Input(), and passes context to @Ctx(). This request returns {"result":{"message":"pong"}}. A FunctionCallError from the function produces an error in the response body.
Give App Store an HTTPS address for your local server. Run the first command if you still need to configure your ngrok auth token. Run ngrok http 3000 in another terminal and leave it running.
If the HTTPS address changes when you restart ngrok, update the Function Endpoint in the Developer Portal. After you add a WAM Endpoint, update both endpoints when the address changes.
Append /functions to the HTTPS URL under Forwarding and save it as the Function Endpoint in the Developer Portal. For example, use https://YOUR-NGROK-DOMAIN/functions. App Store appends /v1 when making a versioned request.
Build and start the server from the project root. pnpm --dir server start loads server/.env. With autoRegister: true, startup registers your app functions in this order.
The SDK uses the App Secret to obtain an app token from App Store.
It uses the app token to register
core:v1, the versioned Extension contract for listing app functions.App Store sends a signed
extension.core.function.getFunctionsrequest to the Function Endpoint to list the functions.The SDK returns the names and input and output schemas from the
@Funcproviders.
When the server logs
Successfully registered extension: core, find Order Management in the test channel's App Store and select Install.Select Developer tools on the app's details page.
In the Functions tab, select
pingand then Execute. Look for{"message":"pong"}in Execution result.
After calling the Function, check the server terminal to see how ctx arrives. This example shows caller and channel information.
ctx.caller.type identifies who made the call. It can be manager (a team member), user (a customer), system (a system process such as an automation), or app (an application). ctx.channel.id identifies the channel for the request. For the full list of fields and their types, see the SDK’s Context type on GitHub.
Add a sample order service and an order lookup Function to the same app.
Create server/src/orders.service.ts with the code below. OrderService stores sample orders in memory per channel. order-1 starts as shipped, and order-2 and order-3 start as pending so you can cancel them later. Restarting the server restores the initial sample orders.
Channel-level authorization
An app can be installed in multiple channels. This example uses ctx.channel.id from the request context to keep each channel's orders separate. When looking up or canceling real orders, also check that the caller has permission to perform that action in the channel.
Create server/src/orders.function.ts with the code below. OrderFunctions uses the channel ID in the request to look up orders in OrderService. When an order is missing, OrderService throws NotFoundError and OrderFunctions converts it to the SDK's FunctionCallError.
Add the imports below to server/src/index.ts, then add OrderService and OrderFunctions to providers in @Module.
Stop the server with Ctrl+C, then rebuild and restart it.
After App Store refreshes the Function list, select getStatus on the Functions tab in Developer tools. The details show the full name, orders.getStatus. Enter order-1 for orderId and select Execute. Check for shipped in the response and the log below in the server terminal.
If a Function is missing, keep the server running and check the core:v1 registration and Function Endpoint. If Execute is disabled, check that you installed the app in the current channel and filled in any required inputs.
Commands let you run app features while chatting. Type / in the team chat message composer to open the command list.
To add a command to your app, use the Command Extension to specify the command's name and the app Function to call. In this step, register command:v1 and use /cancel-order to open the order cancellation screen.
App Store calls
extension.command.metadata.getCommandsto read the definition of/cancel-order.When someone runs the command in team chat, App Store calls the
actionFunctionName,commands.orders.cancel.The action Function returns
type: "wam", the WAM'sname, andwamArgsfor the screen.The Channel Works client appends
nameto the registered WAM Endpoint and loads the screen from that URL.
Create server/src/command.extension.ts with the code below. CommandExtension defines the command, and commands.orders.cancel in CommandActions opens the WAM.
The SDK prefixes functions inside @Extension with extension.<name>., so metadata.getCommands registers as extension.command.metadata.getCommands. Standalone functions such as those in CommandActions keep the full name declared in @Func. Developer tools groups orders.getStatus under orders as getStatus.
Setting | What it does here |
|---|---|
| Shows the command in the Desk. |
| Disables ALF recommendations for the command. Step 5 uses the separate |
| Enables the command by default when the app is installed. |
| Defines the fields and their types in the command form. The order ID is required here. |
| Sends the action request to the |
Command execution requests can also carry fields such as chat and language. App Store puts the values from the command form in the nested input object, so the action reads the order ID from input.input.orderId. Command Extension guide
The name returned by commands.orders.cancel is the path segment added to the WAM Endpoint. Later, when you build the WAM in React, you'll use useWamData("orderId") to read the order ID from wamArgs and display it.
When you build another WAM, set the action's name to the new WAM's name. Keep each WAM's source in wam/<name> and serve its built files under /wam/<name>/.
Add the import below to server/src/index.ts, then add CommandExtension and CommandActions to providers in @Module.
Replace the contents of pnpm-workspace.yaml in the project root with the configuration below. The wam/* pattern adds each WAM as a separate workspace package.
esbuild: true allows the install script for esbuild, which Vite uses.
From the project root, run these commands to scaffold wam/order-cancel with Vite’s React and TypeScript template and install the WAM SDK. Keep the package.json, TypeScript configuration, and ESLint configuration from the template.
Update wam/order-cancel/vite.config.ts as shown below. With base: "./", the built HTML loads JavaScript and other assets relative to /wam/order-cancel/.
Replace the contents of wam/order-cancel/src/main.tsx and wam/order-cancel/src/App.tsx with the code below.
Add the following import at the top of server/src/index.ts.
In the same file, add the code below just before await app.listen(3000). The server serves the static/ directory next to the compiled index.js at /wam.
Append /wam to the HTTPS URL shown under Forwarding in ngrok. In the Developer Portal, open Server Settings for Order Management, enter the URL in WAM Endpoint, and select Save. For example, use https://YOUR-NGROK-DOMAIN/wam.
The Channel Works client appends the name value, order-cancel, to this URL and loads the screen from /wam/order-cancel/.
Stop the server. From the project root, build the server and WAM separately, then start the server again.
Vite writes the WAM build to server/dist/static/order-cancel/.
Check the server log for successful command registration. In channel settings, open App Store, select Order Management, and open the Command tab. Find /cancel-order under Desk Command and turn on its switch if it is off.
In the test channel's team chat, type / in the message composer and select /cancel-order. Enter order-2 and run the command. Check that the WAM displays Order order-2.
If the command is missing, check the command registration log and confirm that the app is installed. If the command appears but the WAM fails to open, check the WAM Endpoint and open http://127.0.0.1:3000/wam/order-cancel/ to check the page.
orders.getStatus reads the order status. Now add orders.cancel to change it. Run the Function in Developer tools or from the WAM opened by /cancel-order. When a manager cancels an order for the first time, read their ID from ctx and notify them through a Native Function.
In server/src/orders.service.ts, add OrderNotCancellableError below NotFoundError.
Add the cancel method below getStatus in OrderService. Only pending orders can be cancelled. The method returns false for an already cancelled order.
Earlier, Channel Works called app functions through App Store. To send the notification, the app server calls Channel Works’ announce Native Function through App Store. The request uses the token for the channel receiving the notification.
In Auth and Access in the Developer Portal, add announce to the Channel role and save.
Create server/src/alert.service.ts with the code below. AlertService obtains a channel token from the TokenManager provided by ChannelAppModule and calls announce. The message goes to the specified manager in My Chatroom.
By default, the SDK’s getChannelToken() caches tokens in memory by channel. It reuses the cached token and refreshes it on a call when it is close to expiring.
In server/src/orders.function.ts, replace the existing ./orders.service.js import with the two lines below.
Add the cancellation input schema, input type, and output schema after GetStatusOutputSchema.
Replace the OrderFunctions constructor with the following to inject AlertService.
Add the cancellation function below getStatus in OrderFunctions. It uses ctx.channel.id to cancel the order in that channel through OrderService. The first time an order is cancelled, AlertService notifies the manager identified by ctx.caller if a manager ID is present.
notification is sent when the announcement is sent and failed if sending fails. It is skipped when the caller is not a manager, the manager ID is missing, or the order was already cancelled. The order stays cancelled if notification fails.
Replace wam/order-cancel/src/App.tsx with the following code. The WAM displays the order ID from the command. Selecting Confirm cancellation runs orders.cancel through useCallFunction.
Finally, replace server/src/index.ts with the code below. It adds AlertService to providers and includes the signature guard and WAM static file mount from the earlier steps.
The WAM hook useCallFunction has no version option. App Store can forward this call to PUT /functions, and the SDK controller listens at PUT /functions/:version. The middleware below runs before NestJS routing and guards and changes only the unversioned request path to /functions/v1. The SDK’s SignatureGuard verifies the original request body for both paths.
Stop the server. From the project root, rebuild the server and WAM separately, then start the server again.
Open Developer tools for the app, select
orders.cancel, and run it withorder-2. Confirmstatus: "cancelled"andnotification: "sent". In Team Chat, select your name to open My Chatroom and look for the messageOrder order-2 was cancelled.In a team chat in the same test channel, choose
/cancel-orderand enterorder-3. Check the order ID in the WAM and select Confirm cancellation. Look forOrder order-3 was cancelled.in My Chatroom.In Developer tools, run
orders.getStatuswithorder-3to confirmcancelled. Calling the cancellation Function for that order again returnsnotification: "skipped".
Keep the server and ngrok running and try orders.getStatus from CoS and ALF in the same test channel.
Call it from CoS. When the installed app exposes the function to CoS, open AI CoS in the left sidebar and ask “Use the Order Management app to check the shipping status of order-1.” Learn about CoS
Use it in an ALF task. Open a test task under Customer → Support → Settings → Tasks. In the AI Agent step, type
@in the instructions and insertorders.getStatusfrom the installed app. Tell ALF to passorder-1asorderIdand report the returnedstatus, then try it in Preview. ALF task guideUse it in an ALF procedure. In a test channel with access to procedures, open the procedure editor under Customer → Support → ALF → Settings → Procedures. Add
orders.getStatuswith the App tool in the instructions and tell ALF to run it after confirming the order ID. Ask fororder-1in the Preview panel. ALF procedure guide (Korean)
In each case, check that the order status is shipped and that the server logged orders.getStatus function call. A typical CoS app call uses manager when it has a team member ID. An ALF task can use manager in a team member's preview, user when it has customer context, or system when it has neither. Check ctx.caller.type in the server log for the call you ran.
You registered app functions, opened a WAM from a Command, and called a Native Function to send a cancellation notification. You also reused the order lookup in CoS and ALF. Stop the server and ngrok when you finish.
Review request directions and authentication in App concepts.
Define names, schemas, requests, and responses with the Function guide.
Add screens and capabilities with the WAM guide and Extension guide.
Review what your production environment needs in App development and operations.
Run the original TypeScript or Go example project with the legacy Quickstart.
This document is maintained with the Channel App SDK. Check the SDK README first for current packages and the complete reading order. The source of truth for this Document is the GitHub source.