Get Live Transcription - Phone Call (Node.js) Telephony
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.
#
Set up SymblTo get started, you’ll need your account credentials and Node.js installed (> v8.x) on your machine.
We’ll use the Symbl module for Node.js in this guide. Make sure you have a Node project set up. If you don’t have one, you can set one up using npm init.
From the root directory of your project, run the following command to add symbl-node
in your project dependencies.
#
Retrieve your credentialsYour credentials include your appId and appSecret. You can find them on the home page of the platform.
#
Initialize SDKIn 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.
#
Make a callThe 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.
- SIP
- PSTN
To make a phone call, call the startEndpoint
with type
set to ‘pstn’ and a valid U.S./Canadian phone number phoneNumber
.
#
Subscribe to the Live ResultsTo 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_response
type is used for low latency live transcription resultsmessage_response
type is used for processed transcription results in real-time. These are not the same astranscript_response
which are low latency but typically generate a few seconds after the processing and contain messages split by sentence boundaries.insight_response
is used for any insights detected in real-time
#
End the CallTo 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.
The 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.
#
CodeYou can find the complete code used in this guide here.
#
TestTo verify and check if the code is working:
- Run your code:
You should receive a phone call to the number you used in the
startEndpoint
call. 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 theconversationId
. If you need to access the results generated in the call, you should invokestopEndpoint
even if it was ended without explicitly invokingstopEndpoint
prior to this point.
#
NoteThe 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 startEndpoint
and stopEndpoint
as needed by the business logic of your application, i.e when you would like Symbl to start processing and stop processing.
#
See alsoCongratulations! 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.