Open nnja opened 4 years ago
Unfortunately, this isn't as straightforward as I originally hoped. Made some progress investigating this after talking to @alphacentauri82 and pairing with @theacodes
Creating a conversation through the Conversations API and using that as our conversation id for outbound calls.
Doesn't work because despite specifying this new Conversation ID in our "connect" NCCO it seems to transfer to a new, unknown conversation UUID. The new, unknown one has the members, but only the members that answer the call.
Checking the conversation status when telephony events arrive.
Doesn't work because the new, unknown conversation id only has members that have answered in it. So we can't trace that back to the conversation ID that has the active members in it, so we can't hangup the call.
import hotline.config
hotline.config.load()
import hotline.injector
import hotline.telephony.lowlevel
client = hotline.injector.get("nexmo.client")
client._jwt_signed_get("/beta2/conversations")
client._jwt_signed_get(f"/beta2/conversations/{conversation_uuid}")
client._jwt_signed_get(f"/beta2/conversations/{conversation_uuid}/members")
client._jwt_signed_get(f"/beta2/conversations/{conversation_uuid}/members/{member_id}")
# Hanging up
client.update_call(f"{conversation_leg_id}", {"action": "hangup"})
Investigate how to fetch in progress calls that might have a status of ringing
Currently, the phone will just play the busy music for forever, even if no one picks up and the call isn't connected.
Detect this case, play a message, and drop the call.
Detecting if the call goes to voicemail may be a necessary prerequisite. References #3
Maybe by modifying the telephony event handler to catch hangups. If no one is left on a call, send a message and disconnect.