This Twilio Flex Plugin adds external cold transfer functionality with phone number validation. It allows agents to transfer calls to external phone numbers with a custom dialog interface.
- External Cold Transfer Button: Adds a button to the call canvas for initiating external cold transfers
- Custom Transfer Dialog: Modal dialog for entering phone numbers
- Phone Number Validation: Validates phone numbers using Twilio Lookup API before transfer
- Error Handling: Comprehensive error notifications and validation messages
- Serverless Functions: Backend functions for secure call transfer operations
Make sure you have Node.js as well as npm. We support Node >= 10.12 (and recommend the even versions of Node).
Install the Twilio CLI by running:
brew tap twilio/brew && brew install twilioInstall the Flex Plugin extension for the Twilio CLI:
twilio plugins:install @twilio-labs/plugin-flexInstall the Serverless Plugin for the Twilio CLI:
twilio plugins:install @twilio-labs/plugin-serverlesscd plugin-external-cold-transfer
npm installThe plugin requires serverless functions for cold transfer operations and phone number validation.
cd ../external-cold-transfer-functions
npm install
twilio serverless:deployAfter deployment, note the Domain from the output. It will look something like:
Domain: external-cold-transfer-functions-XXXX-dev.twil.io
Copy the .env.sample file to .env:
cd ../plugin-external-cold-transfer
cp .env.sample .envEdit the .env file and update the REACT_APP_SERVERLESS_DOMAIN with your deployed serverless domain (without https://):
REACT_APP_SERVERLESS_DOMAIN=external-cold-transfer-functions-XXXX-dev.twil.iocp public/appConfig.example.js public/appConfig.jstwilio flex:plugins:startThis will start the plugin locally and open Flex in your browser.
twilio flex:plugins:deploy --major --changelog "Added external cold transfer functionality" --description "External Cold Transfer Plugin"twilio flex:plugins:release --plugin flex-external-cold-transfer@1.0.0 --name "External Cold Transfer Release" --description "Release external cold transfer plugin"- During an Active Call: The External Cold Transfer button will appear in the call canvas actions (circular button with phone icon)
- Click the Button: Opens a dialog to enter the phone number
- Enter Phone Number: Type the destination phone number
- Transfer: Click "Transfer" to initiate the cold transfer
- The phone number will be validated
- If valid, the call will be transferred
- The task will automatically complete
- ExternalColdTransferButton: Circular button component in call canvas
- ExternalColdTransferDialog: Modal dialog for entering phone numbers
- StartExternalColdTransfer Action: Custom Flex action for handling transfers
- ProgrammableVoiceService: API service for call operations
- PhoneNumberService: API service for phone number validation
- external-cold-transfer: Handles the cold transfer operation using Twilio's Programmable Voice API
- validate-phone-number: Validates phone numbers using Twilio Lookup V2 API
To skip phone number validation (useful for SIP addresses or app: URIs), pass skipPhoneNumberValidation: true in the action payload:
Actions.invokeAction("StartExternalColdTransfer", {
task: task,
phoneNumber: phoneNumber,
callerId: callerId,
skipPhoneNumberValidation: true,
});- Ensure you're on an active call
- Check that the plugin is properly deployed and activated
- Verify serverless functions are deployed
- Check the
.envfile has the correct serverless domain - Ensure phone number is in E.164 format (e.g., +1234567890)
- Check that your Twilio account has access to Lookup API
- Verify the phone number is valid and in correct format
Run twilio flex:plugins --help to see all the commands we currently support. For further details on Flex Plugins refer to our documentation on the Twilio Docs page.
