Skip to content

Add Python/Flask Implementation for Call Handling with Vapi and Twilio #339

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

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

Conversation

cassius66
Copy link

This PR adds a Python/Flask implementation of the call handling solution with Vapi and Twilio.

Changes:

  • Created a complete Python port of the existing JavaScript implementation
  • Used Flask framework instead of Express.js
  • Maintained the same overall architecture and call flow

Improvements over the original implementation:

  • Added specialist confirmation requiring keypress (press 1) to accept calls
  • Implemented smarter voicemail detection based on call duration
  • Created additional endpoints for specialist prompting and response handling

Testing:

  • Tested with Twilio and Vapi integration
  • Verified all call scenarios: successful connection, specialist unavailable, and voicemail detection

Solution to connect a user to a specialist while keeping them on hold. If the specialist does not answer within a specified time or if the call goes to voicemail, the system takes alternative actions.
Copy link
Contributor

@bajajcodes bajajcodes left a comment

Choose a reason for hiding this comment

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

make the changes for other similar snippets.

"""
try:
# Get the base URL
protocol = (
Copy link
Contributor

Choose a reason for hiding this comment

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

raise an exception over the http protocol with a message: "Hey there! Just a heads up Twilio services require HTTPS for security reasons. Make sure your server URL starts with 'https://' instead of 'http://'", as this only works over https.

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.

2 participants