Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transfer call #292

Merged
merged 6 commits into from
Aug 7, 2023
Merged

transfer call #292

merged 6 commits into from
Aug 7, 2023

Conversation

sethgw
Copy link
Contributor

@sethgw sethgw commented Jul 19, 2023

a simple action that will transfer a call #276

@@ -156,5 +162,4 @@ async def handle_ws_message(self, message) -> Optional[PhoneCallWebsocketAction]

def mark_terminated(self):
super().mark_terminated()
asyncio.create_task(self.telephony_client.end_call(self.twilio_sid))

# asyncio.create_task(self.telephony_client.end_call(self.twilio_sid))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is commented out because it immediately disconnects the transferred call if its left in.

response = self.twilio_client.calls(twilio_sid).update(status="completed")

would love some insight here towards a solution here. I thought about using redis to set some kind of conditional flag telling it not to disconnect the call if its being transferred.

any maintainers willing to point me in the right direction?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup agreed, i think there should be a boolean flag for whether or not the call should be completely disconnected (this is useful in cases where we want to end the ws but not the call eg transfer or dtmf)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 we can maybe leverage the active prop on StreamingConversation here. if active, we don't end the call

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do you want the TransferCall action to communicate with StreamingConversation to keep the conversation active when its being transferred?

elif data["event"] == "stop":
            self.logger.debug(f"Media WS: Received event 'stop': {message}")
            self.logger.debug("Stopping...")
            return PhoneCallWebsocketAction.CLOSE_WEBSOCKET

Copy link
Collaborator

@Kian1354 Kian1354 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a good first pass thank you @sethgw – we'll make some changes before merging

from vocode.streaming.models.actions import ActionType


class ActionFactory:
def create_action(self, action_type: str) -> BaseAction:
if action_type == ActionType.NYLAS_SEND_EMAIL:
return NylasSendEmail(should_respond=True)
elif action_type == ActionType.TRANSFER_CALL:
return TransferCall(to_phone="+15555555555")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should change this to support an arbitrary transfer call number

Copy link
Collaborator

@Kian1354 Kian1354 Jul 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think the correct move here is to add an actionconfig (with params you can set). as a workaround to get the pr in for now, what do you think about including this in the TransferCallParameters?

super().__init__(**kwargs)
self.to_phone = to_phone
# TODO: need to support all config managers
self.config_manager = RedisConfigManager()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use the ConversationStateManager here?

or even better just use the TwilioPhoneCallAction
https://github.com/vocodedev/vocode-python/blob/e4cd86b9bca32bb3d65b6e4e4b50caf948775d87/vocode/streaming/action/phone_call_action.py#L31

to grab the sid

@@ -156,5 +162,4 @@ async def handle_ws_message(self, message) -> Optional[PhoneCallWebsocketAction]

def mark_terminated(self):
super().mark_terminated()
asyncio.create_task(self.telephony_client.end_call(self.twilio_sid))

# asyncio.create_task(self.telephony_client.end_call(self.twilio_sid))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup agreed, i think there should be a boolean flag for whether or not the call should be completely disconnected (this is useful in cases where we want to end the ws but not the call eg transfer or dtmf)

Copy link
Contributor

@ajar98 ajar98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just merged in the ActionConfig change: #300

can't commit to your fork so here's a patch to use the new config object here. Also updated it so you don't need the config manager (twilio_sid is already in the TwilioCallAction): https://gist.github.com/ajar98/e8b8fc31d2348fdd285a30b5004d052b

Copy link
Contributor

@ajar98 ajar98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be g2g just one last fix needed here!

vocode/streaming/action/transfer_call.py Outdated Show resolved Hide resolved
@sethgw
Copy link
Contributor Author

sethgw commented Aug 3, 2023

@ajar98 I went ahead and made the http request non-blocking

@sethgw sethgw requested a review from ajar98 August 4, 2023 15:36
Copy link
Contributor

@ajar98 ajar98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good, thanks @sethgw !

@ajar98 ajar98 merged commit 0374074 into vocodedev:main Aug 7, 2023
4 checks passed
m5a0r7 pushed a commit to m5a0r7/vocode-python that referenced this pull request Oct 19, 2023
* transfer call

* action factory

* patch

* get sid

* comment for follow up

* non-blocking
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants