AWS Partner Network (APN) Blog

Adding AI/ML Services to Existing On-Premises and Cloud-Based Contact Centers Through the MRCP Network Protocol

By Arsen Chaloyan, Founder of Universal Speech Solutions LLC – Unispeech.io

Unispeech-AWS-Partners
Unispeech
Connect with Unispeech-1

AWS Contact Center Intelligence (CCI) is a set of solutions available through AWS Partners that are designed to accelerate the adoption of artificial intelligence (AI) and machine learning (ML) into your existing contact center providers hosted on-premises and cloud-based.

These solutions rely on AWS AI services like Amazon Lex, Amazon Transcribe, Amazon Comprehend, Amazon Polly, and Amazon Kendra.

The following use cases are covered by CCI-based solutions:

  • Self-service: Enables companies to build powerful virtual agents, chatbots, and AI-driven interactive voice response (IVR) systems.
  • Real-time call analytics and agent assist: Provides AI-powered conversation analytics in real-time, allowing agents and supervisors to better understand and respond to customer needs quickly.
  • Post-call analytics: Provides insights from recorded conversations that help agents and supervisors better understand customer needs, identify call drivers, and detect emerging trends.

Some contact center platforms don’t offer native integrations with AWS AI/ML services, and it’s an issue when trying to implement one of the CCI use cases. Consequently, customers must learn to live with a “just enough” contact center until their license agreements expire, look for other options beyond AWS, or wait for the platform provider to build the integrations in future releases.

To succeed in this integration challenge, Universal Speech Solutions (also known as Unispeech) created the UniMRCP server and Amazon Lex, Amazon Transcribe, and Amazon Polly plugins that enable the non-native integrations. Unispeech is the implementer of the open-source, cross-platform, and industry-standard Media Resource Control Protocol (MRCPv1 and MRCPv2).

Solution Overview

To show how the UniMRCP Server and its plugins work, Unispeech has built a proof of concept (PoC) environment based on an Ubuntu Linux-based Amazon Machine Image (AMI). It has a preconfigured Asterisk instance, a UniMRCP server, and AI/ML integration plugins.

Unispeech-Contact-Centers-1

Figure 1 – Unispeech PoC environment architecture.

  1. The agents/softphones are configured to connect to Asterisk through the Session Initiation Protocol (SIP) by dialing a preconfigured extension/dial plan.
  2. Asterisk receives the inbound call, welcomes the caller, and uses UniMRCP and its plugins to connect to the Amazon Lex bot.
  3. The Lex bot dispatches the customer phrases during the call until the conversational flow finishes or the user hangs up.

Using the UniMRCP PoC Environment

In this post, I will describe how to use the UniMRCP AMI to connect Asterisk with an Amazon Lex bot, and simulate calls to the PoC environment using a SIP softphone.

I expect this environment to serve as a reference to readers to help you understand how to can connect AWS AI/ML services with existing contact centers using non-native integrations.

Prerequisites

  • Permissions to create Amazon Elastic Compute Cloud (Amazon EC2) instances and Amazon Lex bots.
  • AWS account with the following permissions:
    • Amazon Lex: Run Amazon Lex V2 conversational bots.
    • Amazon Transcribe: Requires permissions to Start Steam Transcriptions using HTTP2/WebSockets.
    • Amazon Polly: SynthesizeSpeech permissions.
    • Amazon CloudWatch: CloudWatchLogsFullAccess is required.
      .
      * Take note of the credentials for this account (AWS ACCESS KEY and AWS SECRET ACCESS KEY). We’ll use them for the UniMRCP Server configuration stage.
      .
  • Unispeech.io account to request the Amazon Lex and Amazon Polly plugin licenses for the UniMRCP server.
  • SIP-compatible softphone to place voice calls to an extension configured in the Asterisk server.

Note that I will use the AWS us-west-2 region for the example in this post.

Walkthrough

Amazon Lex Bot Creation

  1. Log in to the AWS Management Console, switch to the AWS us-west-2 region, and search for Amazon Lex to enter the Lex console.
    .Figure 2 - AWS Management Console search service section.

    Figure 2 – AWS console search service section.

  2. Choose Get Started > Bots > Create bot.
  3. For Creation method, select Start with an example.
  4. Enter a name and description for your bot configuration.
  5. In the AWS Identity and Access Management (IAM) permissions section, create a role with basic Amazon Lex permissions (or reuse an existing role.)
    .
    Figure 3 - Role configuration options for Amazon Lex bot.

    Figure 3 – Role configuration options for Amazon Lex bot.

  6. In the Children’s Online Privacy Protection Act (COPPA) section, select No.
  7. Leave the default values for the remaining fields, and then select Next.
  8. In the Add language to bot step, select Done.
  9. To build the bot, select Build.
  10. After the bot is built, in the Bot details section, take note of the bot ID; this value will be used by the integration.
    .
    Figure 4 - Bot details section showing the bot ID.

    Figure 4 – Bot details section showing the bot ID.

  11. In the Aliases section under Details, take note of the bot alias ID; this value will also be used by the integration.
    .
    Figure 5 - Bot alias details section showing the bot alias ID.

    Figure 5 – Bot alias details section showing the bot alias ID.

UniMRCP AMI Configuration and Launch

  1. In the AWS us-west-2 region, navigate to the Amazon EC2 console, and in the top right corner select Launch instances.
  2. On the Amazon Machine Image selection screen, search for the public image with AMI Name: ubuntu20_ast16_ums_lex_polly, or AMI ID: ami-0fa0fdf047ddaf605. You’ll find one result in community AMIs.
    .
    Figure 6 - Public AMI details for the UniMRCP demo environment.

    Figure 6 – Public AMI details for the UniMRCP demo environment.

  3. Select this image and use a t2.micro free-tier-eligible instance type. Set the storage size to 30 GB.
    .
    Figure 7 - EC2 Instance storage configuration.

    Figure 7 – Amazon EC2 instance storage configuration.

  4. In the security group configuration, create or reuse an existing security group, and add the following rules:
    Type Protocol Port Range Source Description
    SSH TCP 22 Custom <your remote IP address> SSH
    Custom UDP Rule UDP 5060 Custom <your remote IP address> SIP Port
    Custom UDP Rule UDP 10000-10010 Custom <your remote IP address> RTP Port Range
  5. Review and launch the EC2 instance by creating or selecting an existing key pair. I recommend assigning this instance a static IP address using an elastic IP address.

Getting and Adding UniMRCP Server Trial Licenses

We’ll use an SSH client to connect to the EC2 instance using the following instructions:

  1. Locate the private key file you used to launch your instance and run the following commands:
    chmod 400 <your private key file>
    ssh -i "<your private key file>" ubuntu@<your server ip address>
    cd
    sudo /opt/unimrcp/bin/unilicnodegen
    exit
    
  2. Download to your local disk the text file uninode.info generated by the previous command in your home directory using the SFTP command:
    sftp -i "unimrcpserver.pem" ubuntu@<your server ip address>
    get uninode.info
    bye
    
  3. To submit license requests in the UniMRCP website, complete the following steps:
    1. Navigate to Unispeech.io and set up an account.
    2. Log in to your account.
    3. Select Products > Amazon Web Services > Lex.
    4. In the Obtain License section, provide the following information:
      License Variation: Trial
      License Term: 90-day
      License Type: Node-bound
      License Quantity: 2
    5. Select Add to cart.
    6. Select Products > Amazon Web Services > Speech Synthesis.
    7. In the Obtain License section, provide the following information:
      License Variation: Trial
      License Term: 90-day
      License Type: Node-bound
      License Quantity: 2
    8. Select Add to cart.
    9. Select View cart. You should see the items Lex Bot Service and Polly Speech Synthesis.
    10. Select Proceed to checkout, review the terms and conditions, check the box if you agree with the terms and conditions, and select Place order.
    11. In the Discussion > Add Reply section, attach the retrieved uninode.info file to the order and select Send.
    12. Your request will be processed within one business day (or less). You’ll receive email notifications about the status of your request.
    13. After your order is processed, log in to Unispeech.io, select Orders, and view the details of your order to get the trial licenses attached to it.
  4. After you download your licenses, upload them to the UniMRCP server using the following sample commands:
    cd path/to/my/downloaded/unimrcp/licenses/directory
    sftp -i "unimrcpserver.pem" ubuntu@<your server ip address>
    cd
    put umslex_197f5d90-8ace-4291-a2de-812c76774aa6.lic
    put umspolly_c1d36fae-00b1-41be-9f31-2bb46d1314cd.lic
    bye
    ssh -i "unimrcpserver.pem" ubuntu@<your server ip address>
    sudo cp umslex_*.lic /opt/unimrcp/data
    sudo cp umspolly_*.lic /opt/unimrcp/data
    

AWS AI Services Access Configuration

  1. To connect to use the AWS AI services, you need to create an IAM profile with the following policy:
    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Action": "lex:StartConversation",
          "Resource": "arn:aws:lex:us-west-2:<Your account ID>:bot-alias/<Bot ID>/<Bot Alias ID>"
        },
        {
          "Effect": "Allow",
          "Action": [
            "polly:SynthesizeSpeech",
            "transcribe:StartStreamTranscriptionWebSocket",
            "polly:DescribeVoices"
          ],
          "Resource": "*"
        }
      ]
    }
    
  2. After you have finished, go to the EC2 UniMRCP server instance details, select Actions > Security > Modify IAM role, and set the IAM role to the one you created in the previous step.
    .
    Figure 8 - UniMRCP EC2 Instance IAM role configuration.

    Figure 8 – UniMRCP EC2 instance IAM role configuration.

  3. Connect to the UniMRCP Server and edit the following configuration files:
    1. Amazon Polly plugin file – run the following command:
      sudo nano /opt/unimrcp/conf/umspolly.xml
      
    2. In the UMS Polly Document section of this file, change the credentials-provider attribute from “custom” to “default”. Save and exit.
      <umspolly license-file="umspolly_*.lic" credentials-file="aws.credentials" credentials-provider="default" init-sdk="true" shutdown-sdk="true" sdk-log-level="0">
      
    3. Amazon Lex plugin file – run the following command:
      sudo nano /opt/unimrcp/conf/umslex.xml
      
    4. In the UMS Lex Document section of this file, change the credentials-provider attribute from “custom” to “default”. Save and exit.
      <umslex license-file="umslex_*.lic" credentials-file="aws.credentials" credentials-provider="default" init-sdk="true" shutdown-sdk="true" sdk-log-level="0">
      

Asterisk Server Configuration

  1. Edit the UniMRCP config file for Asterisk:
    sudo nano /etc/asterisk/mrcp.conf
    
  2. For the default profile ums2, replace the 172.31.22.59 address with the private IP address of your UniMRCP server instance. Because both the Asterisk and UniMRCP Server are installed on the same instance, the parameters server-ip, client-ip, and rtp-ip must be set to the same IP address.
    [ums2]
    server-ip = <Private IP Address of your UniMRCP server instance>
    client-ip = <Private IP Address of your UniMRCP server instance>
    rtp-ip = <Private IP Address of your UniMRCP server instance>
    

Amazon Lex Chatbot

  1. Edit the UniMRCP config file for Asterisk:
    sudo nano /usr/share/asterisk/agi-bin/agi_lexv2.py
    
  2. Search for the line of code that says:
    self.message = "Welcome to travel agency"
    

    Change it to:

    self.message = "Welcome to travel agency. Would you like to book a Hotel or a Car?"
    
  3. Save the file and exit the text editor.

Dial Plan Configuration

  1. Edit the asterisk dial plan with the following command:
    sudo nano /etc/asterisk/extensions.conf
    
  2. Search for the extension 700 and set the parameters AWS_BOT_ID, AWS_ALIAS_ID, and AWS_REGION corresponding to your Lex bot deployment.
    exten => 700,1,Answer()
    exten => 700,2,Set(AWS_BOT_ID=<Your bot ID>)
    exten => 700,3,Set(AWS_ALIAS_ID=<Your bot alias ID>)
    exten => 700,4,Set(AWS_REGION="us-west-2")
    
  3. Save the file and exit the text editor.

SIP Settings

  1. Edit the asterisk NAT settings issuing with the following command:
    sudo nano /etc/asterisk/sip.conf
    
  2. Replace the localnet and externaddr values with your instance’s private and public IP addresses:
    localnet=<Private IP Address of your UniMRCP server instance>/255.255.255.0
    externaddr=<Public IP Address of your UniMRCP server instance>
    nat=yes
    

Restarting Asterisk

After configuring the Asterisk server, restart the service:

sudo systemctl restart asterisk

Putting it all together

In this example, I downloaded a SIP softphone to our mobile phone and our computer, and created a SIP profile using the following settings:

Domain: <your server IP public address>
Username: astums
Password:123

Dial the extension 700 in your softphone. The call will be attended by the bot I built previously.

Conclusion

In this post, I introduced UniMRCP, an AWS Contact Center Intelligence (CCI) partner solution created by Universal Speech Solutions to communicate existing contact centers that don’t support a native integration with AWS AI/ML services.

This solution enables AWS customers to leverage their existing investments or long-term license agreements with on-premises and cloud contact center providers.

To learn more about the integration and how to extend this example to other SIP-enabled Telephony systems, see the UniMRCP documentation.

For more information on AWS Partners who can help with implementations of this use case, visit the AWS CCI website.

The content and opinions in this blog are those of the third-party author and AWS is not responsible for the content or accuracy of this post.

.
Unispeech-Blog-CTA-1
.


Universal Speech Solutions – AWS Partner Spotlight

Universal Speech Solutions (Unispeech) is an AWS Partner and the implementer of the open-source, cross-platform, and industry-standard Media Resource Control Protocol (MRCPv1 and MRCPv2).

Contact Unispeech | Partner Overview

*Already worked with Unispeech? Rate the Partner

*To review an AWS Partner, you must be a customer that has worked with them directly on a project.