Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AVR Webhook Service

Discord GitHub Repo stars Docker Pulls Ko-fi

A robust Express.js web service designed to handle webhook events from AVR Core. This service provides a clean and intuitive API for processing various types of events generated during voice interactions.

Features

  • Express.js based web service
  • Security middleware (Helmet, CORS, Rate Limiting)
  • Comprehensive logging for all events
  • Request validation and error handling
  • Event-specific handlers for different webhook types
  • Health check endpoint
  • Graceful shutdown handling

Installation

  1. Install dependencies:
npm install
  1. Copy environment configuration:
cp .env.example .env
  1. Configure your environment variables in .env

  2. Start the service:

# Development
npm run start:dev

# Production
npm start

API Endpoints

Health Check

GET /health

Returns the service health status and version information.

Response:

{
  "status": "healthy",
  "timestamp": "2024-01-15T10:30:00.000Z",
  "service": "avr-webhook",
  "version": "1.0.0"
}

Webhook Events

POST /events

Main endpoint for receiving webhook events from AVR Core.

Request Body:

{
  "uuid": "unique-event-identifier",
  "type": "event-type",
  "timestamp": "2024-01-15T10:30:00.000Z",
  "payload": {
    // Event-specific data
  }
}

Response:

{
  "success": true,
  "message": "Event processed successfully",
  "eventId": "unique-event-identifier",
  "processedAt": "2024-01-15T10:30:00.000Z"
}

Supported Event Types

Event Type Description Payload Example
call_started Call initiation {}
call_ended Call termination {}
transcription Speech-to-text result { role, text }
interruption User interruption {}
dtmf_digit User digit { digit }
error Error occurred { message }

Configuration

Environment Variables

Variable Description Default
PORT Server port 3000
NODE_ENV Environment development
ALLOWED_ORIGINS CORS allowed origins *
RATE_LIMIT_MAX Max requests per IP per 15min 100
WEBHOOK_SECRET Webhook signature secret -

Security Features

  • Helmet: Security headers
  • CORS: Cross-origin resource sharing
  • Rate Limiting: Prevents abuse (100 requests per 15 minutes per IP)
  • Request Validation: Validates required fields
  • Error Handling: Comprehensive error responses

Event Processing

The service includes dedicated handlers for each event type:

  • Call Events: Track call lifecycle
  • Transcription Events: Process speech-to-text results
  • LLM Events: Handle AI responses
  • TTS Events: Manage text-to-speech completion
  • Error Events: Log and alert on errors
  • Agent Events: Track agent connections
  • User Input Events: Process user interactions
  • System Events: Handle system messages

Development

Running in Development Mode

npm run start:dev

Uses nodemon for automatic restarts on file changes.

Docker Support

# Build image
npm run dc:build

# Push to registry
npm run dc:push

Error Handling

The service provides comprehensive error handling:

  • 400 Bad Request: Missing required fields
  • 404 Not Found: Invalid endpoints
  • 429 Too Many Requests: Rate limit exceeded
  • 500 Internal Server Error: Processing errors

All errors include timestamps and descriptive messages.

Logging

The service logs:

  • All incoming requests with IP addresses
  • Event processing details
  • Errors with full stack traces
  • Service startup and shutdown events

Integration with AVR Core

Configure AVR Core to send webhooks to this service:

# In avr-core service .env
WEBHOOK_URL=http://localhost:3000/events
WEBHOOK_SECRET=your-webhook-secret-here
WEBHOOK_TIMEOUT=3000
WEBHOOK_RETRY=3

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

Support & Community

Support AVR

AVR is free and open-source. If you find it valuable, consider supporting its development:

Support us on Ko-fi

License

MIT License - see the LICENSE file for details.

About

A robust Express.js web service designed to handle webhook events from AVR Core. This service provides a clean and intuitive API for processing various types of events generated during voice interactions.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.