This is a C# (.NET 8) implementation of the Owl Shoes Conversation Relay application, originally written in Node.js. It demonstrates Twilio's Conversation Relay features with OpenAI integration and Airtable for low-code configuration.
- 🏁 Low-latency streaming responses using WebSockets
- ❗️ Dynamic prompt configuration via Airtable
- 📔 Maintains conversation history with GPT
- 🛠️ Supports function calling:
- getWeather from OpenWeatherMap
- changeLanguage during conversations
- placeOrder (simulates order confirmation and sends SMS)
Sign up for the following services and get API keys:
For local development, use a tunneling service like ngrok.
Create an appsettings.Development.json file with your configuration:
{
"TwilioAccountSid": "your-twilio-account-sid",
"TwilioAuthToken": "your-twilio-auth-token",
"FromNumber": "+1234567890",
"Server": "your-server.ngrok.io",
"OpenAiApiKey": "your-openai-api-key",
"AirtableApiKey": "your-airtable-api-key",
"AirtableBaseId": "your-airtable-base-id",
"WeatherKey": "your-weather-api-key",
"RecordingEnabled": false
}dotnet restoreFollow the same Airtable setup as the Node.js version. Use the sample table or create your own with matching fields.
ngrok http 5000Update the Server setting in your configuration with the ngrok URL (without http:// or https://).
dotnet runOr for development with hot reload:
dotnet watch runPoint your Twilio phone number webhook to:
https://your-server.ngrok.io/incoming
Access the monitoring interface at:
https://your-server.ngrok.io/monitor.html
OwlShoes/
├── Configuration/
│ └── AppSettings.cs # Configuration model
├── Controllers/
│ ├── IncomingController.cs # Handles incoming Twilio calls
│ └── LogsController.cs # Provides log data for monitoring
├── Functions/
│ ├── WeatherFunction.cs # Weather lookup function
│ ├── PlaceOrderFunction.cs # Order placement function
│ └── ChangeLanguageFunction.cs # Language change function
├── Middleware/
│ └── WebSocketHandler.cs # WebSocket connection handler
├── Models/
│ └── Models.cs # Data models
├── Services/
│ ├── AirtableService.cs # Airtable integration
│ ├── GptService.cs # OpenAI GPT integration
│ ├── TextService.cs # Text-to-speech service
│ ├── RecordingService.cs # Call recording service
│ ├── LogService.cs # Logging service
│ ├── FunctionRegistry.cs # Function registration
│ └── IServices.cs # Service interfaces
├── wwwroot/
│ └── monitor.html # Log monitoring UI
├── Program.cs # Application entry point
├── appsettings.json # Base configuration
└── OwlShoes.csproj # Project file
- Dependency Injection: Uses .NET's built-in DI container
- Strongly Typed: All configurations and models are strongly typed
- Async/Await: Native async support throughout
- Structured Logging: Uses Serilog for structured logging
- Middleware Pipeline: Uses ASP.NET Core middleware for WebSocket handling
- The application uses .NET 8.0 with nullable reference types enabled
- WebSocket handling is implemented as custom middleware
- Function calling is implemented using a registry pattern for extensibility
- All services are registered in the DI container for easy testing and maintenance
For production deployment, consider:
- Using Azure App Service with WebSocket support enabled
- Setting up proper SSL certificates
- Configuring application insights for monitoring
- Using Azure Key Vault or similar for secrets management
MIT