sensitive-blue
sensitive-blue2y ago

Getting call transcript in Python

I can obtain the call transcript by copy/pasting from the dashboard. Is there a way to get back the call transcript in Python? I can't find it in the documentation.
12 Replies
Ask Inkeep
Ask Inkeep2y ago
Hi @MelonUsk, I'm an AI assistant for Vapi. I'll analyze available sources and get back to you shortly. ----------------------------- While I generate an answer, here are some sources that might be helpful: * List Credentials * Get Credential * Outbound Calls from Python * Get Call -----------------------------
Ask Inkeep
Ask Inkeep2y ago
Answer Yes, you can retrieve the call transcript in Python by using the Vapi API to get details of a specific call. Once you have the call's ID, you can use the "Get Call" endpoint to fetch the call details, which includes the transcript. Here is a simplified example of how you could achieve this:
import requests

# Your Vapi API Authorization token
auth_token = '<YOUR AUTH TOKEN>'
# The ID of the call you want the transcript for
call_id = '<CALL ID>'

# Create the header with Authorization token
headers = {
'Authorization': f'Bearer {auth_token}',
}

# Make the GET request to Vapi to retrieve the call details
response = requests.get(
f'https://api.vapi.ai/call/{call_id}', headers=headers)

# Check if the request was successful and print the transcript
if response.status_code == 200:
print('Transcript:', response.json().get('transcript'))
else:
print('Failed to retrieve call details')
print(response.text)
import requests

# Your Vapi API Authorization token
auth_token = '<YOUR AUTH TOKEN>'
# The ID of the call you want the transcript for
call_id = '<CALL ID>'

# Create the header with Authorization token
headers = {
'Authorization': f'Bearer {auth_token}',
}

# Make the GET request to Vapi to retrieve the call details
response = requests.get(
f'https://api.vapi.ai/call/{call_id}', headers=headers)

# Check if the request was successful and print the transcript
if response.status_code == 200:
print('Transcript:', response.json().get('transcript'))
else:
print('Failed to retrieve call details')
print(response.text)
This code sample demonstrates how to use the "Get Call" endpoint to fetch details about a specific call, including its transcript, by making a GET request with the call ID. Replace <YOUR AUTH TOKEN> with your actual Vapi API authorization token and <CALL ID> with the ID of the call you're interested in (1) . Remember, to use this script, you'll need to have already made a call or have a call ID that was generated by your Vapi application. You can find more detailed information about the "Get Call" endpoint in the Vapi documentation.
Sources [1] Get Call
sensitive-blue
sensitive-blueOP2y ago
How can I get the most recent call_id ?
genetic-orange
genetic-orange2y ago
get /call and first array item will be the most recent call.
sensitive-blue
sensitive-blueOP2y ago
Hi Sahil, can you share how to get /call in Python? Or point me to relevant docs? Thanks!
sensitive-blue
sensitive-blueOP2y ago
import requests url = "https://api.vapi.ai/call/{. id. }" headers = {"Authorization": "Bearer <token>"} response = requests.request("GET", url, headers=headers) print(response.text) This is what I'm asking - how can I get the most recent {id} ?
genetic-orange
genetic-orange2y ago
you don’t need to provide the id
sensitive-blue
sensitive-blueOP2y ago
Getting this error when not providing the id: {"message":["id must be a UUID"],"error":"Bad Request","statusCode":400}
No description
genetic-orange
genetic-orange2y ago
remove the /{id}
sensitive-blue
sensitive-blueOP2y ago
Thank you for your help and patience! response.json()[0]['transcript'] did it for me 😄
genetic-orange
genetic-orange2y ago
Awesome

Did you find this page helpful?