Alex Contreras
05/04/2024, 2:38 PMVapi Support
05/04/2024, 2:38 PMVapi Support
05/04/2024, 2:38 PMstartedAt
and endedAt
timestamps for a call, calculate the difference in your server or webhook logic, and then convert that difference into seconds.
Given the example timestamps you provided, here's a general approach in Python to calculate the duration in seconds:
python
from datetime import datetime
# Example timestamps
started_at = datetime.strptime("4 May 2024 10:46", "%d %b %Y %H:%M")
ended_at = datetime.strptime("4 May 2024 10:46", "%d %b %Y %H:%M")
# Calculate duration in seconds
duration_seconds = (ended_at - started_at).total_seconds()
print("Call duration in seconds:", duration_seconds)
This script assumes that the startedAt
and endedAt
timestamps are in the format "day month year hour:minutes". Adjust the datetime format in strptime
to match the format you receive.
Please note, however, the actual implementation detail of sending this calculated duration to your webhook depends significantly on your server or webhook setup. You'll likely need to capture these timestamps from the call report data sent to your webhook, perform the calculation as shown above, and then include the calculated duration in the subsequent requests or processing logic within your system.
Regarding the functionality directly within Vapi or its documentation, the specific details on capturing startedAt
and endedAt
timestamps and sending calculated durations are not directly covered in the provided information sources. Thus, implementing the calculation and sending logic would be a task for your server or webhook processing code based on the timestamps provided by Vapi's call report data.Vapi Support
05/04/2024, 2:40 PMSahil
05/04/2024, 4:36 PMVapi Support
05/04/2024, 4:36 PMVapi Support
05/04/2024, 4:37 PMVapi Support
05/05/2024, 3:24 PM