-
Notifications
You must be signed in to change notification settings - Fork 346
Add AI-Ready updates to voice-ivr project #609
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0ef796a
Update README, create .env.example and AGENTS.md
micaswyers-work 660f294
Apply suggestions from code review
micaswyers-work 06dbc1d
Update README tunneling instructions
micaswyers-work 0097349
Empty commit to trigger build
micaswyers-work 5b41a66
Merge branch 'twilio-labs:main' into ai-ready-ivr-js
micaswyers-work File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Your phone number for call forwarding (Sales option) | ||
| # Enter in E.164 format: https://www.twilio.com/docs/glossary/what-e164 | ||
| # Use a test phone number during development | ||
| MY_PHONE_NUMBER=+15551234567 | ||
|
|
||
| # Note: The following Twilio credentials are automatically provided by Twilio Serverless | ||
| # and do not need to be set in your .env file: | ||
| # - ACCOUNT_SID: Your Twilio Account SID (https://www.twilio.com/console) | ||
| # - AUTH_TOKEN: Your Twilio Auth Token (https://www.twilio.com/console) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| # Voice IVR - Agent Guidelines | ||
|
|
||
| This document provides AI assistants with essential information for working with the Voice IVR project. | ||
|
|
||
| ## Project Overview | ||
|
|
||
| The Voice IVR project implements an interactive voice response system using Twilio. The system allows callers to navigate a phone tree using keypad digits or speech recognition. When users call the Twilio number, they can choose between: talking to sales, hearing business hours, or receiving an SMS with the company address. | ||
|
|
||
| ## Documentation Links | ||
|
|
||
| All Twilio documentation URLs in this guide can be accessed in markdown format by adding `.md` to the end of the URL. | ||
|
|
||
| ## Do-Not-Touch Areas | ||
|
|
||
| ### 1. Webhook Signature Verification | ||
|
|
||
| The `.protected.js` suffix on function files indicates they require valid Twilio signatures. Never remove this protection or modify the validation logic. Twilio's serverless toolkit handles this automatically. | ||
|
|
||
| ### 2. Critical Parameters | ||
|
|
||
| Never modify these critical parameters without explicit instructions: | ||
|
|
||
| - `numDigits: 1` in voice-ivr.js - This ensures the system expects a single digit input | ||
| - `input: 'speech dtmf'` in voice-ivr.js - This enables both speech and touch-tone input | ||
| - Webhook paths (`voice-ivr` and `handle-user-input`) - These must match Twilio configurations | ||
|
|
||
| ### 3. Sensitive Data | ||
|
|
||
| Never expose or hardcode these sensitive details: | ||
|
|
||
| - Phone numbers (use environment variables) | ||
| - Twilio account credentials | ||
| - Customer information received during calls | ||
|
|
||
| ## Coding Conventions | ||
|
|
||
| **TwiML must be returned via callback**: All functions must call `callback(null, twiml)` to return TwiML responses. Never use `return twiml` directly. | ||
|
|
||
| ```javascript | ||
| const twiml = new Twilio.twiml.VoiceResponse(); | ||
| twiml.say('Message to speak'); | ||
| callback(null, twiml); // Required pattern | ||
| ``` | ||
|
|
||
| ## Tests | ||
|
|
||
| Run `npm test` from the repository root. Comprehensive test coverage exists in `tests/` for both functions, covering DTMF inputs, speech recognition, error handling, and SMS delivery. | ||
|
|
||
| ## Common Tasks | ||
|
|
||
| ### Adding a New Menu Option | ||
|
|
||
| To add a new menu option (e.g., "Support"): | ||
|
|
||
| 1. Add new option in `voice-ivr.protected.js`: | ||
| ```javascript | ||
| gather.say('Press 4 or say Support to get technical help'); | ||
| ``` | ||
|
|
||
| 2. Add speech recognition and handler in `handle-user-input.protected.js`: | ||
| ```javascript | ||
| // In speech normalization section | ||
| if (UserInput.toLowerCase().includes('support')) { | ||
| UserInput = '4'; | ||
| } | ||
|
|
||
| // In switch statement | ||
| case '4': | ||
| twiml.say('Connecting you to our support team'); | ||
| twiml.dial(context.SUPPORT_PHONE_NUMBER); | ||
| break; | ||
| ``` | ||
|
|
||
| 3. Add any necessary environment variable to `.env`: | ||
| ``` | ||
| SUPPORT_PHONE_NUMBER=+15551234567 | ||
| ``` | ||
|
|
||
| 4. Add any required unit tests | ||
|
|
||
| ## Further Resources | ||
|
|
||
| - [Twilio TwiML Voice Documentation](https://www.twilio.com/docs/voice/twiml) | ||
| - [Twilio Speech Recognition](https://www.twilio.com/docs/voice/twiml/gather#speechmodel) | ||
| - [Twilio SMS Documentation](https://www.twilio.com/docs/sms) | ||
| - [Twilio Serverless Functions](https://www.twilio.com/docs/runtime/functions) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.