Integrate ServiceNow voice assistant with Amazon Connect
Enable users to get support from AI voice agents by integrating a ServiceNow voice assistant with Amazon Connect.
Before you begin
- Create a voice assistant. See Create an AI voice assistant for more information.
- Access to your Amazon Connect instance with permissions to create Lambda functions, configure contact flows, and manage Identity and Access Management (IAM) roles.
Role required: sn_aia.admin
About this task
Connect your Amazon Connect contact center to a ServiceNow voice assistant using the Public Switched Telephone Network (PSTN) communication channel. When a call arrives, Amazon Connect invokes a Lambda function that retrieves a PSTN number from the ServiceNow Call Context API and transfers the call to the voice assistant. After the voice assistant handles the interaction, the Lambda function retrieves the interaction context and routes the call to a queue or ends the call.
Procedure
- Navigate to All > Conversational Interfaces > Assistant Designer > Assistants.
- Find the voice assistant that you want to connect to Amazon Connect and select Edit.
- Select Communication channels from the guided setup navigation.
- In the Provider application field, select the provider application to deploy the voice assistant to.
- Select the Telephony provider tab.
- From the Select communication channels dropdown, select Public Switched Telephone Network (PSTN).
-
From the CCaaS provider dropdown, select Amazon
Connect.
The following read-only fields are generated in the Call context service section. Copy and save these values — you will need them to configure the integration on the Amazon Connect side.
Table 1. Amazon Connect configuration fields Field Description Transfer method Read-only. Set to BYE for Amazon Connect. Call context API Read-only. The URL that Amazon Connect uses to send call context data to the voice assistant. Copy this value for use as the call_context_api_pathandvoice_service_host_nameLambda environment variables.Client ID Read-only. Generated client ID for OAuth2 authentication. Copy this value for use in the AWS Parameter Store setup. Client Secret Read-only. Generated client secret for OAuth2 authentication. Copy this value for use in the AWS Parameter Store setup. KB doc Reference information for configuring the PSTN connection between Amazon Connect and the ServiceNow voice assistant. See KB3027295 for more information. Figure 1. Amazon Connect integration configuration Also note the voice service
sys_id, which you can find in the URL when viewing the voice service record. You will need this value in the Amazon Connect configuration steps. -
Enable context data persistence for the voice service.
-
Navigate to
sys_now_assist_deployment_config_attributes.list. - Filter the list to find the configuration attribute records for your voice service.
-
Locate the attribute named
persist_context_dataand change its value from false to true.This setting allows the Lambda function to retrieve interaction context data from ServiceNow after the voice assistant completes the call.
-
Navigate to
-
In your AWS account, create the Lambda function that connects Amazon Connect to
the voice assistant.
- From the AWS console, create a new Lambda function.
- In the Lambda function code editor, replace the default handler code with the Lambda function code.
-
Set the following environment variables on the Lambda function.
Table 2. Lambda environment variables Variable Value call_context_api_pathThe path portion of the ServiceNow call context URL — the part of the URL after .com.now_instance_host_nameThe ServiceNow instance URL. now_instance_nameThe name of your ServiceNow instance. ssm_oauth_pathThe AWS Parameter Store path for OAuth credentials. Set after completing the Parameter Store setup in the following steps. voice_service_host_nameThe hostname from the ServiceNow call context URL. -
Grant your Amazon Connect instance permission to invoke the Lambda
function.
In the Amazon Connect console, navigate to your instance, select Flows, and under AWS Lambda, add the Lambda function with the Invoke Lambda use case. Confirm the policy was added in the Lambda console under Configuration > Permissions.
-
Replace the Lambda execution role permissions policy with the Identity
and Access Management (IAM) policy.
See Amazon Connect Lambda Identity and Access Management (IAM) policy.
In the Lambda console, navigate to Configuration > Permissions > Execution Role and replace the existing permissions policy. Replace
<region>,<account-id>, and<lambda-function-name>with your values. -
Create a CloudWatch log group for the Lambda function.
In the AWS console, navigate to CloudWatch > Log Management. If no log group exists for your Lambda function, create one named
/aws/lambda/<your_Lambda_name>. -
Create the OAuth credentials in AWS Parameter Store.
From the AWS console, navigate to Parameter Store and create the following parameters using SecureString as the type.
Table 3. Parameter Store entries Name Value /com.servicenow.cti/<sn-instance-id>/<voice-service-id>/client_idWhere
sn-instance-idis the value of theinstance_idsystem property, andvoice-service-idis the voice servicesys_id.Client ID from the ServiceNow voice service configuration. /com.servicenow.cti/<sn-instance-id>/<voice-service-id>/client_secretWhere
sn-instance-idis the value of theinstance_idsystem property, andvoice-service-idis the voice servicesys_id.Client Secret from the ServiceNow voice service configuration. -
Add the AWS PowerTools layer to the Lambda function.
In the Lambda console, navigate to the Lambda function and select Layers. Add the AWS layer
AWSLambdaPowertoolsTypeScriptV2, version 2.33.0 or later.
-
Import and configure the Amazon Connect contact flow.
-
In your Amazon Connect instance, create a new contact flow by
importing the Voice AI inbound flow JSON.
See Amazon Connect Voice AI inbound flow.
In the Amazon Connect console, navigate to Routing > Flows, select Create flow, then use the import option. Replace all placeholder values with your own before importing.
-
In the first AWS Lambda function block of the contact flow, set the
function ARN to the Lambda you created and set the
voice_service_idinput parameter to thesys_idof the voice service. - In the second AWS Lambda function block, set the function ARN to the same Lambda function.
-
Save and publish the contact flow.
Note:When Amazon Connect transfers the call to ServiceNow, the contact flow must pass the original caller's phone number as the caller ID. Verify that your contact flow is configured to preserve the original caller ID during the transfer, not the Amazon Connect transfer number.
-
In your Amazon Connect instance, create a new contact flow by
importing the Voice AI inbound flow JSON.
-
Associate a phone number with the contact flow.
- In the Amazon Connect service dashboard, navigate to Channels > Phone numbers.
-
Claim a new number or select an existing number to associate with the
contact flow.
Associating a phone number with the contact flow enables incoming calls to be routed through the voice assistant.
Result
Amazon Connect is connected to your ServiceNow voice assistant. Incoming calls routed through Amazon Connect are handled by the AI voice agent, which responds with a greeting and processes the caller's requests. When call handling is complete, the contact flow routes the caller to a queue or ends the call.
What to do next
Test the integration by placing a call through your Amazon Connect phone number and verifying that the voice assistant responds correctly. Review the CloudWatch logs for the Lambda function to troubleshoot any connection issues.