Deploy an AI Assistant on Windows: Connect an LLM and Office Platform (Check Node.js Requirements First)
This guide explains how to deploy an AI assistant on Windows using the native command line, connect it to an LLM API and an office platform, store credentials securely, install Node.js and Git, configure dependencies and environment variables, set up long-connection events, and troubleshoot common issues. It also compares WSL, native command-line, and GUI deployment options and ends with an acceptance checklist.
Deploy an AI Assistant on Windows: Connect an LLM and Office Platform
Before you start, check the Node.js version requirements in the framework’s official README. The framework usually requires a specific major version of Node.js.
1. What to Prepare Before Deployment
You need two external resources before deployment: an LLM API key and a developer account for the office platform. Both are directly related to account security, so plan how to store them securely from the beginning.
1.1 LLM API Access
LLM platforms usually charge based on usage. After registration, add a small amount of credit for testing. When choosing a platform, check three things:
- Whether it is compatible with the OpenAI API format
- The maximum context length
- The request limit per minute (rate limiting)
If the platform is compatible with the OpenAI format, you can use the same Base URL and model name configuration in the framework.
After obtaining the key, do not write it into code, take screenshots of it, or paste it into chat tools. Later in this guide, it will be stored as a user environment variable.
1.2 Office Platform Organization and Application
Register an account on the office platform and create an organization. Most platforms offer a free basic organization. After creating the organization, go to the developer console and create a custom application (a bot application). After creation, the platform assigns an App ID and App Secret. These two values are the credentials the framework uses to connect to the platform.
For example, on the Feishu Open Platform, the menu is usually under “Developer Console → Apps → Credentials & Basic Info.” Menu names may change as the platform is updated, so use the interface you actually see.
1.3 Credential Storage Rules
Follow these three rules:
- Store the App Secret and API Key only in local user environment variables or in a
.envfile in the project root. - Add
.envto.gitignoreto avoid committing it to the code repository. - If credentials appear in logs, screenshots, or a repository, immediately reset the key in the platform console and update the local configuration.
2. Choosing Among Three Deployment Methods
There are three common deployment methods on Windows: WSL (Windows Subsystem for Linux), the native command line (PowerShell, CMD, or Git Bash), and a GUI client. The differences are as follows:
| Method | Main dependencies | Network characteristics | Permission requirements | Suitable for | Main failure points |
|---|---|---|---|---|---|
| WSL | Linux distribution, Node.js | WSL and the host network are isolated; mirrored networking mode or port forwarding is required | Virtualization must be enabled | Users familiar with Linux and able to handle proxies | Proxy does not work; the host cannot access the service port |
| Native command line | Node.js, Git, C++ build tools (required by some dependencies) | Uses the Windows network stack directly; minimal configuration | Regular users are sufficient; global npm package installation usually does not require administrator privileges | Ordinary Windows developers | Dependency compilation fails; environment variables do not take effect |
| GUI client | Runtime bundled with the client | Depends on the client’s network settings | Depends on the client | Users who only want a quick trial | Cannot bypass office platform backend configuration; connections may be unstable on certain networks |
If you need deep integration and full control over configuration, choose the native command line. If you are familiar with Linux and the host already has a proxy configured, you can choose WSL. In WSL, you can write [wsl2] and networkingMode=mirrored in %USERPROFILE%\.wslconfig to let the subsystem share the host network. However, this mode requires a newer Windows version such as Windows 11 and is not available on all machines.
The following sections use the native command line as an example.
3. Installing Node.js and Git
3.1 Installation
Use winget to install them. Run these commands in PowerShell:
winget install OpenJS.NodeJS.LTSwinget install Git.Git
The framework usually requires a specific major version of Node.js. Check the “Requirements” section in its official README first and choose an LTS version that meets the requirement. If winget is unavailable, download the .msi installer from the Node.js official website. The official website also provides SHA256 checksums. After downloading, you can compare the hash with the following command:
Get-FileHash .\node-v<version>-x64.msi -Algorithm SHA256
3.2 Verify Versions
After installation, close all terminals and reopen PowerShell. Run:
node -vnpm -vgit --version
All three commands should output version numbers. If the system says that a command “is not recognized as the name of a cmdlet, function, script file, or operable program,” PATH has not taken effect. Proceed to the next step.
3.3 Check the npm Global Directory and PATH
First, check npm’s global installation directory:
npm config get prefix
The default value is usually C:\Users\<username>\AppData\Roaming\npm. After confirming this path, add it to the user PATH. Back up the current user PATH before making changes by exporting it to a text file:
[Environment]::GetEnvironmentVariable("Path","User") | Out-File -Encoding utf8 $HOME\path_backup.txt
After backing up, open “Settings → System → About → Advanced system settings → Environment Variables.” Under “User variables,” select Path, create a new entry, paste the npm directory above, and save. Close and reopen the terminal, then verify again:
where.exe npmnpm --version
where.exe npm should point to the npm directory, and npm --version should return a version number. If the system becomes abnormal after the change, you can restore the PATH contents from the backup file.
4. Configuring a Registry, Cloning the Framework, and Installing Dependencies
4.1 Switch the npm Registry
If npm downloads are slow in your network environment, you can switch to a mirror such as npmmirror:
npm config set registry https://registry.npmmirror.comnpm config get registry
The second command should output the address you just set. A mirror only affects download speed, not package contents. If a package is missing from the mirror, temporarily switch back to the official registry.
4.2 Clone the Framework Code
Use the framework’s official README for the repository address. In the commands below, <framework repository URL> represents that address:
git clone <framework repository URL> ai-assistantcd ai-assistant
Switch to the version tag or branch specified in the README, for example git checkout <version tag>. Do not use the latest code on the default branch unless the README explicitly requires it.
4.3 Install Dependencies
npm install
If you see errors related to gyp ERR!, MSBuild, or node-gyp, a native module usually needs C++ build tools. Install Visual Studio 2022 Build Tools with winget and select the C++ desktop workload:
winget install Microsoft.VisualStudio.2022.BuildTools --override "--wait --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"
After installation, reopen the terminal, delete the node_modules directory and package-lock.json, and run npm install again. Deleting the lock file changes dependency versions, so use this only for troubleshooting and record the change.
4.4 Write the Configuration
Create .env in the project root. Use the field names specified by the framework documentation; the example names below are for illustration:
LLM_BASE_URL=https://<OpenAI-compatible endpoint of the LLM platform>/v1LLM_MODEL=<model name>FEISHU_APP_ID=<app App ID>FEISHU_APP_SECRET=<app App Secret>
Do not write the API Key into .env. Instead, store it as a user environment variable to avoid accidentally sharing the file:
[Environment]::SetEnvironmentVariable("LLM_API_KEY", "<your API Key>", "User")
After setting it, reopen the terminal. To confirm the variable is in effect, check only its length and do not print its contents:
$env:LLM_API_KEY.Length
If the result is 0 or an error occurs, the variable was not set successfully.
5. Office Platform Backend Configuration
5.1 Minimum Permission List
On the application’s “Permission Management” page, enable only the permissions the functionality actually needs. Below is a reference list for a basic bot; the permission identifier format follows the Feishu Open Platform:
im:message.group_at_msg:readonly: Read messages that mention the bot in group chats. Without this permission, the bot cannot detect @mentions in groups.im:message.p2p_msg:readonly: Read direct messages between users and the bot. Enable this if private chat is required.im: Send messages as the bot. This is required when the bot needs to reply.
send_as_bot
Do not enable all permissions just for convenience. The more permissions you grant, the greater the impact if credentials are leaked.
5.2 Enable Long Connection
On the “Events & Callbacks” page, find the event subscription configuration and set the receiving method to “Use long connection to receive events” instead of a Webhook callback URL. With a long connection, the local machine actively establishes an outbound connection to the platform. This does not require a public address or inbound port.
Then add the events you need. The event for receiving messages is usually named im.message.receive_v1. After adding it, go to “Version Management & Release,” create a version, and publish it. Changes to permissions or events do not take effect until they are published. This step is easy to miss.
5.3 Add the Bot to a Group Chat
Add the bot in the group settings of the office platform. Creating an application in the backend does not automatically add it to any group chat.
6. Starting the Service and Troubleshooting
6.1 Start the Service
In the project directory, run the start command from the framework README, for example:
npm start
After starting, return to the “Events & Callbacks” page in the backend and check whether the long-connection status shows “Connected.”
6.2 Troubleshooting Order When the Bot Does Not Receive Group Messages
Check in the following order. Do not skip ahead if the previous step fails:
- Has the application version been published? Permission and event changes do not take effect until the version is published.
- Do the permission identifiers match what the code requires, especially the permission for group @mentions?
- Has the event been added, and is the receiving method set to long connection?
- Has the bot been added to the target group, and was the bot actually @mentioned in the group?
- Is the local process connected successfully? Check the framework logs for authentication failures or connection disconnections. Authentication failures are usually caused by an incorrect App ID or App Secret, or by the configuration file not being read.
- Is the firewall blocking outbound requests? Windows Defender Firewall or third-party security software may block Node.js from accessing the internet. You can temporarily allow outbound connections for
node.exeto verify, then keep only the necessary rules. - Is the LLM call successful? Check the API status code in the framework logs. A 401 usually indicates an API Key error, and 429 indicates rate limiting.
7. Acceptance Checklist
After deployment, confirm each item:
node -v,npm -v, andgit --versionall output version numbers, and the Node.js version meets the framework requirements.npm installfinishes without errors, andnpm config get registryshows the selected registry address.- The App ID, App Secret, model endpoint, and model name in
.envare filled in, and.envhas been added to.gitignore. - The office platform backend shows the long-connection status as “Connected,” and the application version has been published.
- Send a test message by @mentioning the bot in a group chat. The bot should reply within a reasonable time, and the logs should contain no errors.
Once all items pass, deployment is complete. If you need to add features later, enable the required permissions and repeat the publishing step in Section 5.
