Get a live transcription in your Node.js application by making a call to a valid phone number. In this guide, we will walk you through how to get a live transcription and real-time AI insights, such as follow-ups, action items, topics and questions of a phone call using a PSTN or SIP connection.
symbl-node node package.
Making a phone call is also the quickest way to test Symbl’s Telephony API. It can make an outbound call to a phone number using a traditional public switched telephony network (PSTN), any SIP trunks, or SIP endpoints that can be accessed over the internet using a SIP URI.
In this example we use the following variables which you must replace in the code examples for the code to work:
Set up Symbl SDK#
From the root directory of your project, run the following command to add
symbl-node in your project dependencies.
Retrieve your credentials#
Your credentials include your appId and appSecret. You can find them on the home page of the platform.
Create a new file named index.js in your project and add the following lines to initialize the Symbl SDK:
The quickest way to test the Telephony API is to make a call to any valid phone number. The Telephony API only works with phone numbers in the U.S. and Canada.
Your application uses the SDK to:
make a REST call to the Telephony API with the phone number details
subscribe to live results over a WebSocket connection
Once the call is accepted on the phone, the Telephony API starts receiving audio from the call.
Live transcription is streamed back to your application using the WebSocket connection.
To make a phone call, call the
type set to
pstn and a valid U.S./Canadian phone number
phoneNumber. The connection will return a
To get real-time AI insights, you must subscribe to the connectiohn. You need to call the
subscribeToConnection method in the SDK and pass the
connectionId and a callback method which will be called on for every new event including the live transcription.
When you use this API, you can use a callback function within the
subscribeToConnection function. You pass an object and declare the type of response you want in the type field.
transcript_responsetype is used for low latency live transcription results
message_responsetype is used for processed transcription results in real-time. These are not the same as
transcript_responsewhich are low latency but typically generate a few seconds after the processing and contain messages split by sentence boundaries.
insight_responseis used for any insights detected in real-time
To end the call, you should make a
stopEndpoint call. The following code stops the call after 60 seconds. Your business logic should determine when the call should end.
stopEndpoint will return an updated
connection object which will have the
conversationId in the response. You can use
conversationId to fetch the results even after the call using the Conversation API.
You can find the complete code used in this guide here.
To verify and check if the code is working:
- Run your code:
You should receive a phone call to the number you used in the
startEndpointcall. Accept the call.
Start speaking in English (default language) and you should see the live transcription added to the console in real-time.
The call should automatically end after 60 seconds. If you end it sooner and don’t invoke
stopEndpoint, you will not receive the
conversationId. If you need to access the results generated in the call, you should invoke
stopEndpointeven if it was ended without explicitly invoking
stopEndpointbefore this point.
The example above invokes
stopEndpoint after a fixed timeout of 60 seconds. This is for demonstrating the stop functionality and it is not the recommended method of implementation for your application. In a real implementation, you should invoke
stopEndpoint as needed by the business logic of your application, i.e when you would like Symbl to start processing and stop processing.
Congratulations! You finished your integration with Symbl’s Telephony API using PSTN. Next, you can learn more about the Conversation API, SIP Integration, Post-Meeting Summary, and Active Speaker Events.