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

Fix the issue of Twilio sometimes starting a new websocket connection for the same call concurrently #61

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kevinmershon
Copy link

I noticed in testing that Twilio sometimes re-invokes a websocket connection during the call which was resulting in duplicated streams running and me hearing multiple confused TTS voices at different stages of my call flow. By refusing to initiate more than one call per unique calling phone number, this problem was completely eliminated for me.

If it helps, I was calling from a cellphone with wifi-based calling enabled so I considered it's possible that when a cellphone switches from wifi-calling back to the 4G network that Twilio thinks the stream was interrupted and tries to open a new webosocket.

Contributing to Twilio

All third-party contributors acknowledge that any contributions they provide will be made under the same open-source license that the open-source project is provided under.

  • I acknowledge that all my contributions will be made under the project's license.


let interactionCount = 0;

transcriptionService.on('utterance', async (text) => {
Copy link
Author

Choose a reason for hiding this comment

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

all of this code is just moved from below into this bindCall wrapper.

ttsService.generate({partialResponseIndex: null, partialResponse: 'Hello! I understand you\'re looking for a pair of AirPods, is that correct?'}, 0);

getCallerNumber(msg.start).then((number) => {
if (activeCalls[number]) {
Copy link
Author

Choose a reason for hiding this comment

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

refuse to initiate multiple streams for the same inbound/from caller number

@kevinmershon kevinmershon force-pushed the bugfix-twilio-stream-restart-fix branch from 5763141 to 9b79929 Compare October 8, 2024 18:38
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.

1 participant