Via WebSockets
WebSocket conversations support the same features as webhook conversations but are much more flexible. Because you will run your own server that manually forwards audio chunks between Phonic and your own audio interface, you can implement offline tools and use your own audio interface, via telephony, web, or otherwise.
In this guide we’ll demonstrate the basic mechanics of WebSocket conversations. The example code for this guide is available here.
Open a WebSocket connection to Phonic
The first step is to open a WebSocket connection to Phonic, which sends and receives various types of messages, detailed here.
On the receiving side, the most important message is the audio_chunk_response, which contains the
Phonic-generated audio that your server will forward to your audio interface, along with its transcript.
Similarly, on the sending side, the most important message is the audio_chunk, which contains the user audio
that your server will forward to Phonic.
Here is an example implementation of this WebSocket connection:
Open a connection with your audio interface
Now that your server is open and receiving messages from Phonic, you can use any audio interface for the user. Here is a simple example using Twilio: