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.
To follow along with this guide, you should have the following elements set up and ready to use:
Each time you wish to search, the following operations need to take place:
Let's run through each of these steps now.
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.
1fetch("https://ai.twilio.com/v1/Tokens", {2"headers": {3"authorization": `Basic ${btoa(ACCOUNT_SID + ":" + AUTH_TOKEN)}`,4"content-type": "application/json"5},6"body": JSON.stringify({7"grants": [{8"product": "intelligence-discovery"9}]10}),11"method": "POST"12});
1fetch("https://ai.twilio.com/v1/Tokens", {2"headers": {3"authorization": `Basic ${btoa(ACCOUNT_SID + ":" + AUTH_TOKEN)}`,4"content-type": "application/json"5},6"body": JSON.stringify({7"ott_ttl": 600,8"grants": [{9"product": "annotator",10"service_sid": "GA00000000000000000000000000000000",11"transcript_sid": "GT00000000000000000000000000000000",12"metadata": {13"userId": "Jason Bourne",14"isDownloadButtonVisible": true15}16}]17}),18"method": "POST"19});
1{2"token": "eyJ6a...",3"expiration": "2020-08-27T17:22:00Z"4}
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.
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:
Check out the standalone
endpoint in the Transcripts App Integration Demo for a sample implementation of this flow.
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:
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.
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.
Request the OTT providing a viewLinks
config on the metadata:
1const viewLink = "http://localhost:8080/annotator/standalone?serviceSid=:serviceSid&transcriptSid=:transcriptSid";23fetch("https://ai.twilio.com/v1/Tokens", {4"headers": {5"authorization": `Basic ${btoa(ACCOUNT_SID + ":" + AUTH_TOKEN)}`,6"content-type": "application/json"7},8"body": JSON.stringify({9"grants": [{10"product": "intelligence-discovery",11"viewLinks": {12"conversationViewLink": viewLink13}14}]15}),16"method": "POST"17});
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";
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.