Integrate the Transcripts App
Public Beta
Voice Intelligence is currently available as a public beta release. Some features are not yet implemented and others may be changed before the product is declared as Generally Available. Beta products are not covered by a Twilio SLA.
Learn more about beta product support.
This guide shows you how to integrate the Transcripts App facility into your web app. It is intended for developers and system integrators, and assumes that you have at least one working Voice Intelligence Service.
The Transcripts App is a web applet your web app can retrieve, initialize, and present within its own UI. It allows a user to search through transcripts of recorded conversations that took place between participants.
You can present the Transcripts App as part of your site's UI, or in its own window that pops up when it is required. We’ll show you how to achieve both. In each case, your app requests the Transcription Viewer code by calling a specific URL and including an authorization token as a URL parameter.
A Transcripts App Integration Demo companion project that implements the topics discussed in this guide is available on GitHub for reference.
Prerequisites
To follow along with this guide, you should have the following elements set up and ready to use:
- Twilio account credentials, specifically your Account SID and your Auth Token, which you can get from the Console.
- Access to transcripts that you would like to search.
Instructions
Each time you wish to search, the following operations need to take place:
- Your Account SID, Auth Token, and some metadata are used to acquire a one-time token.
- Pass the one-time token as a URL query parameter to initialize the Transcripts App.
Let’s run through each of these steps now.
1. Acquire a one-time token
Each Transcript App session requires a new one-time token (OTT). This is a short-lived, single-use key that is used to authorize access to the transcript to be searched.
The request to acquire a token requires your global Twilio account credentials, so server-side usage requires a secure environment. Do not expose your Twilio account credentials to clients.
You request the OTT by making a call to this endpoint:
https://ai.twilio.com/v1/Tokens
You use your Account SID and Auth Token to authorize the request, which is submitted as JSON. Check out the examples below to see how the request body JSON is formatted.
You can also include a default Service SID in the OTT request’s metadata
section if you wish. This is optional. It should be used to choose the selected service on the initial load. This usage is shown in the examples below.
You may also specify a custom token expiry period, called a TTL (Time To Live). The default value is one minute, and that’s what’s applied to the first of the following examples. The second example sets a TTL of 10 minutes (600 seconds) by adding an ott_ttl
field to the request body.
With this data, you can acquire a one-time token. The basic structure of the request is shown below. The request JSON also includes a mandatory product
field. This indicates the app you’re requesting the token for — intelligence-discovery
in this case.
The one-time token is used internally by the Transcripts app to acquire a fully privileged and scoped access token for use during the lifetime of its session. It can be used once only. It’s purpose is to avoid embedding a fully privileged access token in client-side code.
2. Initialize the Transcripts App
Once you’ve acquired a one-time token, pass it as a URL query parameter with your request for the Transcripts app itself. The latest Transcripts App build is available here:
https://assets.twilio.com/public_assets/intelligence-discovery/latest/index.html
So to request the app with the one-time token, just add a token
parameter to the URL as follows:
https://assets.twilio.com/public_assets/intelligence-discovery/latest/index.html?token=$TOKEN
This assumes your token is stored in an environment variable called TOKEN
. You can now use this URL directly, or via an iframe in your web page HTML, as the following examples show.
Example 1: Use the Transcripts App in a standalone window
If your app will present the Transcripts App functionality in its own browser window, open a new window and load its contents with the latest build as shown above. Make sure you include the one-time token as a URL query parameter.
The entire flow might then be:
- The frontend issues a request to a backend service.
- The backend service uses locally stored Twilio account credentials to generate a one-time token.
- The backend service redirects the browser to the latest Transcription Viewer build with the token appended to the app’s URL.
Check out the standalone
endpoint in the Transcripts App Integration Demo for a sample implementation of this flow.
Example 2: Embed Transcrips App inside your web app
The Transcripts App can be embedded in an HTML iframe. To do so, add the URL and appended token to the iframe markup like this:
<iframe src="https://assets.twilio.com/public_assets/intelligence-discovery/latest/index.html?token={THE_ONE_TIME_TOKEN}">
To achieve this, your server will likely need to retrieve and then dynamically embed the token into the HTML.
The entire flow might then be:
- The frontend issues a request to a backend service.
- The backend service uses locally stored Twilio account credentials to generate a one-time token.
- The backend service renders an HTML page that contains the iframe snippet above.
Take a look at the embedded
endpoint Transcripts Integration Demo for a sample implementation of this flow.
If the Transcripts App is empty you might need to change the Service name selection or Date range filters.
Only the last 90 days transcriptions are available in the Transcriptions App to search and view.
If you still don't see any transcription, please check your Service configuration or create new Transcripts.
3. Optionally, link the Transcripts App to the Transcription Viewer
Once you have loaded the Transcript App with some transcripts, you have the possibility to link each transcript shown in the search results to the Transcription Viewer app to present a selected transcript. To do so, you will need to include the view links configuration in your one-time token request. This URL needs to have placeholders for a service SID and a transcript SID. These placeholders (respectively the strings :serviceSid
and :transcriptSid
) will be substituted by the Transcript App with the actual service SID and transcript SID values.
The following examples show how this works.
Example 3: Use the Transcription Viewer app with view link
Request the OTT providing a viewLinks
config on the metadata:
const viewLink = "http://localhost:8080/annotator/standalone?serviceSid=:serviceSid&transcriptSid=:transcriptSid";
fetch("https://ai.twilio.com/v1/Tokens", {
"headers": {
"authorization": `Basic ${btoa(ACCOUNT_SID + ":" + AUTH_TOKEN})`,
"content-type": "application/json"
},
"body": JSON.stringify({
"grants": [{
"product": "intelligence-discovery",
"viewLinks": {
"conversationViewLink": viewLink
}
}]
}),
"method": "POST"
});
Example 4: Use the Transcript App with view link when PII is enabled
If PII has been enabled on any of the services, the required URL will require the sensitive
parameter with a placeholder value. The placeholder is the string :sensitive
. Transcript App will present links for the sensitive and/or non-sensitive transcript.
const viewLink = "http://localhost:8080/annotator/standalone?serviceSid=:serviceSid&transcriptSid=:transcriptSid&sensitive=:sensitive";
Integration FAQs
What is a one-time token?
The one-time token (OTT) is used internally by the Transcripts app to acquire a fully privileged access token for use during the lifetime of a search operation. It is short lived — approximately one minute — and can be used once only. Its purpose is to avoid embedding a fully privileged access token in client-side code.
How is token refresh handled?
Token refresh is not supported during preview. The one-time token is exchanged for a token with a time to live of one hour.