Get the live transcription in your Node.js application by making a call to a valid phone number.
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.
From the root directory of your project, run the following command to add
symbl-node in your project dependencies.
Your credentials include your appId and appSecret. You can find them on the home page of the platform.
In a new file called index.js in the project, add the following lines to import and initialize the SDK. Replace the appId and appSecret in the code with yours.
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 REST call to Telephony API with phone number details and then Symbl makes the call
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 subscribed WebSocket connection.
To make a phone call, call the
type set to ‘pstn’ and a valid U.S./Canadian phone number
To get the live transcription, you need to subscribe to the connection to get the results. 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
stopEndpointprior to 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 Conversation API, SIP Integration, Post-Meeting Summary, and Active Speaker Events.