Call Connect#
- class pywa.types.calls.CallConnect#
Represents a call connection event.
This update arrives when a call is initiated by the business or the user.
- Variables:
id β The call ID.
metadata β The metadata of the call (to which phone number this call was made or received).
from_user β The user who participated in the call, either as caller or callee.
timestamp β The timestamp when this call was made (in UTC).
event (CallEvent) β The calling event (always
CONNECT).direction (CallDirection) β Whether the call was initiated by the business or the user.
session (SessionDescription | None) β The session information, including SDP type and SDP info.
shared_data β Shared data between handlers.
- pre_accept(*, sdp)#
Pre-accept the call.
Read more at developers.facebook.com.
In essence, when you pre-accept an inbound call, you are allowing the calling media connection to be established before attempting to send call media through the connection.
When you then call the accept call endpoint, media begins flowing immediately since the connection has already been established
Pre-accepting calls is recommended because it facilitates faster connection times and avoids audio clipping issues.
There is about 30 to 60 seconds after the Call Connect webhook is sent for the business to accept the phone call. If the business does not respond, the call is terminated on the WhatsApp user side with a βNot Answeredβ notification and a Terminate Webhook is delivered back to you.
- Parameters:
sdp (SessionDescription) β Contains the session description protocol (SDP) type and description language.
- Returns:
Whether the call was pre-accepted.
- Return type:
- accept(sdp, *, tracker=None)#
Connect to a call by providing a call agentβs SDP.
Read more at developers.facebook.com.
You have about 30 to 60 seconds after the Call Connect Webhook is sent to accept the phone call. If your business does not respond, the call is terminated on the WhatsApp user side with a βNot Answeredβ notification and a Terminate Webhook is delivered back to you.
- Parameters:
sdp (SessionDescription) β Contains the session description protocol (SDP) type and description language.
tracker (str | CallbackData | None) β The data to track the call with (optional, up to 512 characters, for complex data You can use
CallbackData).
- Returns:
Whether the call was accepted.
- Return type:
- reject()#
Reject the call.
Read more at developers.facebook.com.
You have about 30 to 60 seconds after the Call Connect webhook is sent to accept the phone call. If the business does not respond, the call is terminated on the WhatsApp user side with a βNot Answeredβ notification and a Terminate Webhook is delivered back to you.
- Returns:
Whether the call was rejected.
- Return type:
- terminate()#
Terminate the active call.
Read more at developers.facebook.com.
This must be done even if there is an RTCP BYE packet in the media path. Ending the call this way also ensures pricing is more accurate. When the WhatsApp user terminates the call, you do not have to call this endpoint. Once the call is successfully terminated, a Call Terminate Webhook will be sent to you.
- Returns:
Whether the call was terminated.
- Return type:
- class pywa.types.calls.CallEvent#
Represents the type of call event.
- Variables:
CONNECT β The call is connected.
TERMINATE β The call is terminated.
- class pywa.types.calls.CallDirection#
Represents the direction of a call (who initiated the call).
- Variables:
BUSINESS_INITIATED β The call was initiated by the business.
USER_INITIATED β The call was initiated by the user.
- class pywa.types.calls.SessionDescription#
Contains the Session Description Protocol (SDP) type and description language.