Building an intelligent IVR system with a Bot handling the interaction with your end users and bringing in humans based on pre-defined events would bring a lot of automation and remove mundane manual activities which takes up lot of time for a person. This can be achieved using cloud services provided by cloud providers such as Amazon, Google, Azure etc and communication service providers such as Twilio.
In this post, you will learn about how to create or build an intelligent or smart IVR system using some of the following:
The following is a sample/reference application architecture representing a custom IVR system built using different AWS services (DynamoDB, Lambda, Polly, and S3) and Twilio.
Use Amazon Polly to create custom text-to-speech audio. Store the generated audio with appropriate read permission and content-type/content-length information on AWS S3. Refer to this page, Amazon Polly Text-to-speech with AWS S3, Twilio Java App
The following is the sample IVR instructions which does the following:
The above can be achieved using the following code:
@Override public void playVoice(String toNumber, String voicePath) throws IOException, URISyntaxException { String thankYouPath = "http://s3.amazonaws.com/reminders/thankyou.mp3"; PhoneNumber to = new PhoneNumber(toNumber); // Replace with your phone number PhoneNumber from = new PhoneNumber(this.fromPhoneNumber); // Replace with a Twilio number // // Play custom feedback or query message created using Polly // Play playMessage = new Play.Builder(voicePath).loop(1).build(); // // Record the user input // Record recordMessage = new Record.Builder(). .action(URL_for_invoking_AWS_Lambda).method(HttpMethod.POST). timeout(15).playBeep(true).maxLength(30).finishOnKey("*").build(); // // Play thank you message // Play playThankYouMessage = new Play.Builder(thankYouPath).build(); // // Hang up Hangup hangup = new Hangup.Builder().build(); // // Create a voice response object and corresponding XML // VoiceResponse response = new VoiceResponse.Builder().play(play1).record(record1).play(play2).hangup(hangup1) .build(); String xml = response.toXml(); // // Store the voice XML on AWS S3 InputStream xmlStream = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)); String s3Key = UUID.randomUUID().toString() + ".xml"; String url = this.awsCloudStorage.uploadStream(s3Key, xmlStream, "text/xml"); // // Make the call using programmed voice stored as XML on AWS S3 // Call call = Call.creator(to, from, new URI(url)).setMethod(HttpMethod.GET).create(this.twilioRestClient); System.out.println(call.toString()); }The following is the sample TwiML file which gets created and stored on S3. It is later played by Twilio as a result of outgoing call to the destined user.
<Response> <Play loop="1"></Play> <Record action="API_url_invoking_AWS_Lambda" method="post" finishOnKey="#" maxLength="30" playBeep="true" timeout="15" trim="trim-silence"/> <Play> </Play> <Hangup/> </Response> Further Reading / References
In this post, you learned about creating or building a smart and an intelligent IVR system using Amazon ML services such as Polly, Transcribe, Comprehend, Lambda etc and Twilio Programmable Voice APIs.
Did you find this article useful? Do you have any questions or suggestions about this article in relation to building IVR using Amazon and Twilio services? Leave a comment and ask your questions and I shall do my best to address your queries.
For data scientists and machine learning researchers, 2024 has been a landmark year in AI…
ChatGPT Canvas is a cutting-edge, user-friendly platform that simplifies content creation and elevates collaboration. Whether…
Knowing when to use the LLM such as the ChatGPT O1 model is key to…
In recent years, artificial intelligence (AI) has evolved to include more sophisticated and capable agents,…
Adaptive learning helps in tailoring learning experiences to fit the unique needs of each student.…
With the increasing demand for more powerful machine learning (ML) systems that can handle diverse…