You can use the Voice API to connect a call to a WebSocket, giving you a two-way stream of the call audio delivered over the WebSocket protocol in real-time. This enables you to process the call audio to perform tasks such as sentiment analysis, real-time transcription and decision-making using artificial intelligence.
In this tutorial, you will connect an inbound call to a WebSocket endpoint. The WebSocket server will listen to the call audio and echo it back to you. You will implement this using the Flask web application micro-framework and Flask-Sockets, which lets you define WebSocket endpoints like any other Flask route.
Call a WebSocketConnect an inbound call to a WebSocket with the Voice API