I want to access the transcription text that has been generated by transcribe in my Twilio account under transcriptions as I want to compare user recorded response as text
twiml.say('Hi there! Please speak your response after the beep,-Get ready!')
.record({
transcribe:true,
timeout:5,
maxLength:30,
transcribeCallback:'/recording',
action:'/recording'
});
app.post('/recording', (request,response) => {
if(transcriptionText=='yes'){
twiml.say('thank you for positive response');
}
response.type('text/xml');
response.send(twiml.toString());
});
Twilio developer evangelist here.
When using transcription with
<Record>
, once the recording is complete the call will continue on to make a request to theaction
attribute synchronously. Whatever you return from theaction
attribute URL will control the call.The actual transcription, however, takes a bit more time and when you get a webhook to the
transcribeCallback
URL it is done asynchronously, outside the context of the call. So, returning TwiML will not affect the call at all.You will get the transcription text by inspecting the body of the request. There are plenty of parameters sent to the
transcribeCallback
, but the one you are looking for is theTranscriptionText
. In your Node.js app, which looks like Express to me, you can get hold of it by callingrequest.body.TranscriptionText
.If you do want to affect the call when you receive the transcribe callback you will need to use the REST API to modify the call and redirect it to some new TwiML.
Let me know if that helps at all.
[edit]
From the comments I can see you are trying to drive a part of the call from a spoken response. The
transcribeCallback
URL isn't called immediately as the transcription needs to be done, so you need anaction
URL that you can send your caller to while you wait.So, adjust your recording route to have different endpoints for
action
andtranscribeCallback
:Then your recording endpoint will need to keep the user waiting while Twilio transcribes the text.
Finally, when you get the transcribe callback you can figure out the course from the transcribed text somehow and then redirect the live call into a new endpoint that carries on the call with the new information.