This demo provides a sample implementation for a containerized virtual participant that can join an Amazon IVS Real-time stage, subscribe to content from other participants in the stage, and publish content to the stage as well. The container consists of a Node.js server context and Puppeteer client context that communicate via a WebSocket IPC. The client context uses the IVS Web Broadcast SDK to connect to an IVS Real-time stage.
Caution
Use at Your Own Risk: This is a code sample designed to help developers get started with Amazon IVS. It is not production-ready and will require additional development work to be suitable for production use. It is not intended for production use as-is. Its primary goal is to help developers understand the concepts and capabilities of Amazon IVS. By using this solution, you understand and accept its risks and limitations.
- Asset Publisher - Stream pre-recorded media to a stage
- Nova S2S - Conversational AI with Amazon Nova Sonic
- GPT Realtime - Conversational AI with OpenAI GPT Realtime
- Realtime Captioner - Live transcription and captions
- Deploy to AWS
- VirtualParticipant CLI Commands
- Virtual Participant Configuration
- Sample Implementations
- About Amazon IVS
View full diagram and description.
Before continuing, ensure you have installed the following tools:
- AWS CLI Version 2
- Node.js v20 and
npm(npm is usually installed with Node.js)- If you have node version manager installed, run
nvm useto sync your node version with this project
- If you have node version manager installed, run
- Docker Desktop - Required for building the containerized virtual participant
- Ensure Docker Desktop is running on your system before deployment
For configuration specifics, refer to the AWS CLI User Guide.
npm run deployLaunches an interactive wizard that guides you through the deployment process. You can optionally save deployment configurations locally to simplify re-deploys.
npm run deploy:listDisplays all saved deployment configurations with their details, including virtual participant type, environment, stack name, AWS profile, last deployment timestamp, and deployment count.
npm run deploy:deleteRemoves a saved deployment configuration from local storage. This command will list all saved configurations and allow you to select a deployment to delete.
Example:
npm run deploy:delete
# Select a configuration to delete and confirmIf you prefer not to use the interactive CLI tool to deploy the application stack, you may use the make app command to initialize and deploy a stack, or the make deploy command to re-deploy an existing stack. When using the make <app|deploy> command, use the following environment variables to specify the deploy configuration.
VP: Virtual participant type to deploy. One ofasset-publisher,nova-s2s,gpt-realtime,realtime-captioner(default:asset-publisher). (Optional)asset-publisher: Example asset-based virtual participant that publishes pre-recorded medianova-s2s: Example real-time conversational virtual participant with Amazon Nova Sonicgpt-realtime: Example real-time conversational virtual participant with gpt-realtimerealtime-captioner: Example real-time captioning virtual participant using the Web Speech Recognition API
ENV: Application environment for stack deployment. One ofdevorprod(default:dev). (Optional)STACK: Stack name (default:IVSVirtualParticipant-$(ENV)). (Optional)AWS_PROFILE: Named AWS CLI profile for stack deployment (default:default). (Optional)PUBLIC_API: Enable public HTTP API via API Gateway (default:false). (Optional)
VP=<asset-publisher|nova-s2s|gpt-realtime> STACK=<STACK_NAME> ENV=<dev|prod> PUBLIC_API=<true|false> AWS_PROFILE=default make appBy default, Lambda functions are exposed via IAM-authenticated Lambda Function URLs (private access). You can optionally enable a public HTTP API through API Gateway for simpler prototyping with external applications.
Important note: This will make several functions available publicly, meaning that anyone on the public internet will be able to invoke the functions listed in the Access Methods section through an HTTP call.
When Public API is Disabled (Default):
- Functions use individual Lambda Function URLs with AWS IAM authentication
- Each function has its own URL output in the CloudFormation stack
- AWS credentials are required for access
When Public API is Enabled:
- The following functions are publicly accessible via API Gateway endpoints:
POST <PublicApiUrl>/stage/create- Create a new IVS stagePOST <PublicApiUrl>/stage/delete- Delete an existing IVS stagePOST <PublicApiUrl>/stage/token- Generate a participant tokenPOST <PublicApiUrl>/stage/invite- Invite a virtual participantPOST <PublicApiUrl>/stage/kick- Kick a virtual participant
- The API Gateway URL is included in the CloudFormation stack outputs as
PublicApiUrl
The following CLI commands allow you to interact with IVS stages and the virtual participant.
npm run createStage <stack-name>Creates a new IVS Real-Time stage with a participant token.
Options:
<stack-name>: Name of the stack deployed to an AWS account (Required)
Example:
npm run createStage IVSVirtualParticipant-devnpm run deleteStage -- <stack-name> -s <stage-id> -p <participant-id>Deletes an existing IVS Real-Time stage.
Options:
<stack-name>: Name of the stack deployed to an AWS account (Required)-s, --stageId: ID of the stage to delete (Required)-p, --participantId: ID of the participant to remove from the stage (Required)
Example:
npm run deleteStage IVSVirtualParticipant-dev -s st-abc123 -p pt-def456npm run inviteVp -- <stack-name> -s <stage-id> [-a <asset-name>]Invites a virtual participant to join an existing IVS Real-Time stage.
Options:
<stack-name>: Name of the stack deployed to an AWS account (Required)-s, --stageId: ID of the stage to invite the virtual participant to (Required)-a, --assetName: Name of the asset/video content for the virtual participant. (Optional)
Example:
npm run inviteVp -- IVSVirtualParticipant-dev -s st-abc123npm run inviteVp -- IVSVirtualParticipant-dev -s st-abc123 -a video-1.mp4npm run kickVp -- <stack-name> -s <stage-id>Removes a virtual participant from an IVS Real-Time stage.
Options:
<stack-name>: Name of the stack deployed to an AWS account (Required)-s, --stageId: ID of the stage to remove the virtual participant from (Required)
Example:
npm run kickVp -- IVSVirtualParticipant-dev -s st-abc123npm run listVps -- <stack-name>Lists all virtual participants in the system, grouped by their current status.
Options:
<stack-name>: Name of the stack deployed to an AWS account (Required)
Example:
npm run listVps -- IVSVirtualParticipant-devnpm run listStages -- <stack-name>Lists all IVS Real-Time stages in the system.
Options:
<stack-name>: Name of the stack deployed to an AWS account (Required)
Example:
npm run listStages -- IVSVirtualParticipant-devnpm run stopVps -- <stack-name>Stops all running virtual participant tasks. Once stopped, new tasks will automatically be spawned using the latest task definition based on the minimum number of warm tasks (default: 2) defined in the VP pool manager: lambda/handlers/manageWarmVpPool.ts.
Options:
<stack-name>: Name of the stack deployed to an AWS account (Required)
Example:
npm run stopVps -- IVSVirtualParticipant-devThis demo application uses a public/private key-pair to create and verify participant stage tokens.
- The application generates an ECDSA public/private key pair
- The private key is used to sign JSON Web Tokens (JWTs) on the server
- The public key is imported to Amazon IVS for token verification during stage join
- For more details, see the Amazon IVS documentation on distributing tokens
While the initial key-pair is created automatically when deploying the backend stack, you may need to rotate these keys periodically or immediately if you suspect the private key has been compromised.
To manually rotate the key-pair, run the following command:
npm run rotateKeyPair -- <stack-name>Note that any running VirtualParticipant tasks must be restarted after rotating the token key-pair.
Options:
<stack-name>: Name of the stack deployed to an AWS account (Required)
Example:
npm run rotateKeyPair -- IVSVirtualParticipant-devYou can configure virtual participant behavior using the environment variables available in .env.example. These variables are automatically passed to the ECS container at deployment time, with the ECS_ prefix removed. Copy the example .env.example file to .env and replace the placeholder values as needed:
cp .env.example .envWhen deploying the nova-s2s virtual participant, you can customize the following settings:
ECS_NOVA_MODEL_ID: Nova Sonic model ID (default:amazon.nova-sonic-v1:0)ECS_NOVA_VOICE_ID: Voice ID for responses (default:matthew. View available voices in the Amazon Nova docs.)ECS_NOVA_SYSTEM_PROMPT: Custom system prompt to define AI behavior (default: "You are a helpful AI assistant in a video conversation. Be conversational, friendly, and engaging.")BEDROCK_REGION: AWS region for Bedrock services (default:us-east-1)
Example:
# Set in your .env file or export before deployment
export ECS_NOVA_VOICE_ID="matthew"
export ECS_NOVA_SYSTEM_PROMPT="You are a helpful AI assistant in a video conversation. Be conversational, friendly, and engaging."
# Then deploy
npm run deployWhen deploying the gpt-realtime virtual participant, you must provide an OpenAI API Key:
ECS_OPENAI_API_KEY: OpenAI API Key, with access to gpt-realtime
Example:
# Set in your .env file or export before deployment
export ECS_OPENAI_API_KEY="sk_..."
# Then deploy
npm run deployImportant Notes for Nova S2S:
- Your deployment AWS account must have Amazon Bedrock access
- Nova Sonic must be enabled through Bedrock model access in your deployment region
- You must define a BEDROCK_REGION where Amazon Nova Sonic is available (default:
us-east-1) - Be sure to monitor your Bedrock usage, as Nova Sonic is billed per audio minute
Several sample implementations are provided as docker containers in the virtualparticipants/ directory.
This sample implementation streams pre-recorded content from an S3 bucket to the real-time stage. Follow the deploy instructions and select asset-publisher to deploy this sample.
This sample implementation demonstrates a real-time conversational AI persona using Amazon Nova Sonic via Amazon Bedrock. The AI persona can engage in natural voice conversations with stage participants, with customizable voice options and system prompts. Follow the deploy instructions and select nova-s2s to deploy this sample.
This sample implementation demonstrates a real-time conversational AI persona using the GPT realtime API. The AI persona can engage in natural voice conversations with other stage participants, with customizable voice options and system prompts. Follow the deploy instructions and select gpt-realtime to deploy this sample.
This sample implementation demonstrates real-time captioning capabilities using speech recognition. The virtual participant can join a stage, subscribe to audio from other participants, and generate real-time captions/transcriptions of the spoken content. Follow the deploy instructions and select realtime-captioner to deploy this sample.
Amazon Interactive Video Service (Amazon IVS) is a managed live streaming and stream chat solution that is quick and easy to set up, and ideal for creating interactive video experiences. Learn more.
- Amazon IVS docs
- User Guide
- API Reference
- Setting Up for Streaming with Amazon Interactive Video Service
- Learn more about Amazon IVS on IVS.rocks
- View more demos like this
See CONTRIBUTING for more information.
This library is licensed under the MIT-0 License. See the LICENSE file.





