Conner
Conner2mo ago

TranscriptId while inside agent

Hi @Tico | Voiceflow Assistant how would you grab the transcriptId of the current conversation while in session
4 Replies
Tico | Voiceflow Assistant
Voiceflow doesn’t expose a {transcriptId} variable while the dialog is running. • During a live session only the sessionID / userID is known inside the agent.
• A transcript record (and its _id, the transcriptId) is created only when you call the Transcripts API (PUT https://api.voiceflow.com/v2/transcripts) or when the web-chat widget makes that same call for you.
• The API response returns the new record, e.g.
{ "_id": "6695a11bab10e059b87753e8", ... }
{ "_id": "6695a11bab10e059b87753e8", ... }
Capture that _id in your front-end code or in a Voiceflow Function block that makes the call, then store it in a variable if you still need it later in the flow. So, inside the agent you would: 1. Make the PUT /transcripts request when you’re ready to save the conversation (pass your projectID, versionID and the current sessionID/userID). 2. Read response.json._id – that’s the transcriptId. 3. Put that value into a Voiceflow variable (via the Function block’s outputVars) if you need to reference it elsewhere in the dialog. If you’re using the out-of-the-box Web Chat, listen for the widget’s transcript-save callback (it runs the same API call) and grab the returned _id there. Docs: https://developer.voiceflow.com/v2.0/reference/put_transcripts Voiceflow only assigns a transcriptId once you create / save a transcript through the Transcripts API.
1. Call the PUT /v2/transcripts endpoint from a Code step (or from your front-end) as soon as the session starts – you just need:
{
"projectID": "<projectID>",
"versionID": "<versionID>",
"sessionID": "<userID-or-sessionID>"
}
{
"projectID": "<projectID>",
"versionID": "<versionID>",
"sessionID": "<userID-or-sessionID>"
}
2. The 200 response comes back with an object that contains:
{
"_id": "6695a11bab10e059b87753e8", // <-- this is the transcriptId
"projectID": "...",
"sessionID": "...",
...
}
{
"_id": "6695a11bab10e059b87753e8", // <-- this is the transcriptId
"projectID": "...",
"sessionID": "...",
...
}
3. Store the returned _id in a VF variable if you need to tag the transcript, add notes, etc. later in the same conversation.
Because a transcript doesn’t exist until you make that call, there isn’t a built-in variable you can reference “live” – you have to trigger the save yourself (web-chat does this automatically for you under the hood).
Docs: https://developer.voiceflow.com/v2.0/reference/put_transcripts
Steve B. | IntelleSync.ai
@Conner I can help with this if you haven't figured it out already.
Conner
ConnerOP2mo ago
@Steve B. | IntelleSync.ai I got it Steve, but thanks buddy 🙂
Steve B. | IntelleSync.ai
@Conner Great stuff! 😀

Did you find this page helpful?