Skip to main content
This guide will walk you through setting up a minimal example of an interactive AI avatar using a backend built with TypeScript and Express.

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:
Never expose your API key in the browser. The server reads it from .env and returns only a short-lived session token to the client.
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 ts-node for quick testing without a separate build step:
Open http://localhost:3000 in your web browser, allow microphone access, and click Connect.