Getting call transcript in Python
# support
m
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.
v
Hi @Muffins, 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]() -----------------------------
### 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:
Copy code
python
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.
m
How can I get the most recent
call_id
?
s
get /call and first array item will be the most recent call.
m
Hi Sahil, can you share how to get /call in Python? Or point me to relevant docs? Thanks!
m
import requests url = "https://api.vapi.ai/call/{. id. }" headers = {"Authorization": "Bearer "} response = requests.request("GET", url, headers=headers) print(response.text) This is what I'm asking - how can I get the most recent {id} ?
s
you don’t need to provide the id
m
s
remove the /{id}
m
Thank you for your help and patience!
response.json()[0]['transcript']
did it for me 😄
s
Awesome
2 Views