Prerequisites
- A TruGen API key (get one here)
- A TruGen Agent ID (create and get one here)
- Node.js installed on your machine
- A modern web browser with microphone access
Project Setup
1
Install Dependencies
Initialize a new project and install the required runtime and development dependencies:
2
Configure TypeScript
Create a
tsconfig.json file in the root of your project:3
Set Up Project Structure
Set up the following directory layout:
4
Add Your Credentials
Create a
.env file and add your API key and Agent ID:5
Create the Server
Create
server.ts — this fetches the session token on the backend to keep your credentials secure:6
Create the HTML Frontend
Create
public/index.html. The frontend runs plain browser JS and imports the SDK from esm.sh directly, so no TypeScript compilation is required for the client side:7
Run the Application
Start the server with Open
ts-node for quick testing without a separate build step:http://localhost:3000 in your web browser, allow microphone access, and click Connect.