Do your employees wait for hours on the telephone to open an IT ticket? Do they wait for an agent to triage an issue, which sometimes only requires restarting the computer? Providing excellent IT support is crucial for any organization, but legacy systems have relied heavily on human agents being available to intake reports and triage issues. Conversational ai (or chatbots) can help triage some of these common IT problems and create a ticket for the tasks when human assistance is needed. Chatbots quickly resolve common business issues, improve employee experiences, and free up agents’ time to handle more complex problems.
QnABot on AWS is an open source solution built using AWS native services like Amazon Lex, Amazon OpenSearch Service, AWS Lambda, Amazon Transcribe, and Amazon Polly. QnABot version 5.4+ is also enhanced with generative ai capabilities.
According to Gartner Magic Quadrant 2023, ServiceNow is one of the leading IT Service Management (ITSM) providers on the market. ServiceNow’s Incident Management uses workflows to identify, track, and resolve high‑impact IT service incidents.
In this post, we demonstrate how to integrate the QnABot on AWS chatbot solution with ServiceNow. With this integration, users can chat with QnABot to triage their IT service issues and open an incident ticket in ServiceNow in real time by providing details to QnABot.
Watch the following video to see how users can ask questions to an IT service desk chatbot and get answers. For most frequently asked questions, chatbot answers can help resolve the issue. When a user determines that the answers provided are not useful, they can request the creation of a ticket in ServiceNow.
Solution overview
QnABot on AWS is a multi-channel, multi-language chatbot that responds to your customer’s questions, answers, and feedback. QnABot on AWS is a complete solution and can be deployed as part of your IT Service Desk ticketing workflow. Its distributed architecture allows for integrations with other systems like ServiceNow. If you wish to build your own chatbot using Amazon Lex or add only Amazon Lex as part of your application, refer to Integrate ServiceNow with Amazon Lex chatbot for ticket processing.
The following diagram illustrates the solution architecture.
The workflow includes the following steps:
- A QnABot administrator can configure the questions using the Content Designer UI delivered by Amazon API Gateway and Amazon Simple Storage Service (Amazon S3).
- The Content Designer Lambda function saves the input in OpenSearch Service in a question’s bank index.
- When QnABot users ask questions prompting ServiceNow integration, Amazon Lex fetches the questions and requests the user to provide a description of the issue. When the description is provided, it invokes a Lambda function.
- The Lambda function fetches secrets from AWS Secrets Manager, where environment variables are stored, and makes an HTTP call to create a ticket in ServiceNow. The ticket number is then returned to the user.
When building a diagnostic workflow, you may require inputs to different questions before you can create a ticket in ServiceNow. You can use response bots and the document chaining capabilities of QnABot to achieve this capability.
Response bots are bots created to elicit a response from users and store them as part of session variables or as part of slot values. You can use built-in response bots or create a custom response bot. Response chatbot names must start with the letters “QNA.”
This solution provides a set of built-in response bots. Refer to Configuring the chatbot to ask the questions and use response bots for implementation details.
You can use document chaining to elicit the response and invoke Lambda functions. The chaining rule is a JavaScript programming expression used to test the value of the session attribute set to elicit a response and either route to another bot or invoke Lambda functions. You can identify the next question in the document by identifying the question ID (QID) specified in the Document Chaining:Chaining Rule field as ‘QID::‘ followed by the QID value of the document. For example, a rule that evaluates to “QID::Admin001” will chain to item Admin.001.
When using a chaining rule for Lambda, the function name must start with the letters “QNA,” and is specified in the Document Chaining:Chaining Rule field as ‘Lambda::FunctionNameorARN’. All chaining rules must be enclosed in a single quote.
Deploy the QnABot solution
Complete the following steps to deploy the solution:
- Choose Launch Solution on the QnABot implementation guide to deploy the latest QnABot template via AWS CloudFormation.
- Provide a name for the bot.
- Provide an email where you will receive an email to reset your password.
- Make sure that EnableCognitoLogin is set to true.
- For all other parameters, accept the defaults (see the implementation guide for parameter definitions), and launch the QnABot stack.
This post uses a static webpage hosted on Amazon CloudFront, and the QnABot chatbot is embedded in the page using the Amazon Lex web UI sample plugin. We also provide instructions for testing this solution using the QnABot client page.
Create a ServiceNow account
This section walks through the steps to create a ServiceNow account and ServiceNow developer instance:
- First, sign up for a ServiceNow account.
- Go to your email and confirm this email address for your ServiceNow ID.
- As part of the verification, you’ll will be asked to provide the six-digit verification code sent to your email.
- You can skip the page that asks you to set up two-factor authentication. You’re redirected to the landing page with the ServiceNow Developer program.
- In the Getting Started steps, choose Yes, I need a developer oriented IDE.
- Choose Start Building to set up an instance.
When the build is complete, which may take couple of seconds to minutes, you will be provided with the instance URL, user name, and password details. Save this information to use in later steps.
- Log in to the site using the following URL (provide your instance):
https://devXXXXXX.service-now.com/now/nav/ui/classic/params/target/change_request_list.do
.
Be sure to stay logged in to the ServiceNow developer instance throughout the process.
If logged out, use your email and password to log back in and wake up the instance and prevent hibernation.
- Choose All in the navigation bar, then choose Incidents.
- Select All to remove all of the filters.
All incidents will be shown on this page.
Create users in ServiceNow and an Amazon Cognito pool
You can create an incident using the userid of the chatbot user. For that, we need to confirm that the userId of the chatbot user exists in ServiceNow. First, we create the ServiceNow user, then we create a user with the same ID in an Amazon Cognito user pool. Amazon Cognito is an AWS service to authenticate clients and provide temporary AWS credentials.
- Create a ServiceNow user. Be sure to include a first name, last name, and email.
Note down the user ID of the newly created user. You will need this when creating an Amazon Cognito user in a user pool.
- On the Amazon Cognito console, choose User pools in the navigation pane.
If you have deployed the Amazon Lex web UI plugin, you will see two user pool names; if you did not, you’ll see only one user pool name.
- Select the user pool that has your QnABot name and create a new user. Use the same userId as that of the ServiceNow user.
- If you are using the Amazon Lex web UI, create a user in the appropriate Amazon Cognito user pool by following the preceding steps.
Note that the userId you created will be used for the QnABot client and Amazon Lex Web UI client.
Create a Lambda function for invoking ServiceNow
In this step, you create a Lambda function that invokes the ServiceNow API to create a ticket.
- On the Lambda console, choose Functions in the navigation pane.
- Choose Create function.
- Select Author from scratch.
- For Function name, enter a name, such as
qna-ChatBotLambda
. (Remember that QnABot requires the prefixqna-
in the name.) - For Runtime, choose Node.js 18.x.
This Lambda function creates new role. If you want to use an existing role, you can change the default AWS Identity and Access Management (IAM) execution role by selecting Use existing role.
- Choose Create function.
- After you create the function, use the inline editor to edit the code for index.js.
- Right-click on
index.js
and rename it toindex.mjs
. - Enter the following code, which is sample code for the function that you’re using as the compute layer for our logic:
This function uses the ServiceNow Incident API. For more information, refer to Create an incident.
- Choose Deploy to deploy this code to the $LATEST version of the Lambda function.
- On the Configuration tab, in the Environment variables section, add the following:
-
- Add
SERVICENOW_HOST
with the valuedevXXXXXX.service-now.com
. - Add
SERVICENOW_USERNAME
with the valueadmin
.
- Add
-
- Copy the Lambda function ARN. You will need it at later stage.
The next step is to store your ServiceNow user name and password in Secrets Manager.
- On the Secrets Manager console, create a new secret.
- Select Other type of secret.
- Add your key-value pairs as shown and choose Next.
- For Secret name, enter a descriptive name (for this post, servicenow/password). If you choose a different name, update the value of const
secret_name
in the Lambda function code. - Choose Next.
- Leave Configure rotation on default and choose Next.
- Review the secret information and choose Store.
- Copy the ARN of the newly created secret.
Now let’s give Lambda permissions to Secrets Manager.
- On the Lambda function page, go to the Configurations tab and navigate to the Permissions section.
- Choose the execution role name to open the IAM page for the role.
- In the following inline policy, provide the ARN of the secret you created earlier:
- Add the inline policy to the role.
Configure QnABot configurations
In this section, we first create some knowledge questions using the Questions feature of QnABot. We then create a response bot that elicits a response from a user when they ask for help. This bot uses document chaining to call another bot, and triggers Lambda to create a ServiceNow ticket.
For more information about using QnABot with generative ai, refer to Deploy generative ai self-service question answering using the QnABot on AWS solution powered by Amazon Lex with Amazon Kendra, and Amazon Bedrock.
Create knowledge question 1
Create a knowledge question for installing software:
- On the AWS CloudFormation console, navigate to the QnABot stack.
- On the Outputs tab, and open the link for
ContentDesignerURL
. - Log in to the QnABot Content Designer using admin credentials.
- Choose Add to add a new question.
- Select qna.
- For Item ID, enter software.001.
- Under Questions/Utterances, enter the following:
- Under Answer, enter the following answer:
- Expand the Advanced section and enter the same text in Markdown Answer.
- Leave the rest as default, and choose Create to save the question.
Create knowledge question 2
Now you create the second knowledge question.
- Choose Add to add a new question.
- Select qna.
- For Item ID, enter
knowledge.001
. - Under Questions/Utterances, enter
Want to learn more about Amazon Lex
. - Under Answer, enter the following answer:
- Expand the Advanced section and enter the same answer under Markdown Answer.
- Leave the rest as default, and choose Create to save the question.
Create knowledge question 3
Complete the following steps to add another knowledge question:
- Choose Add to add a new question.
- Select qna.
- For Item ID, enter
password.reset
. - Under Questions/Utterances, enter I need to reset my password.
- Under Answer, enter the following answer:
- Expand the Advanced section and enter the same text for Markdown Answer.
- Choose Create to save the question.
Create a response bot
Complete the following steps to create the first response bot, which elicits a response:
- Choose Add to add a new question.
- Select qna.
- For Item ID, enter
ElicitResponse.001
. - Under Questions/Utterances, enter
Please create a ticket
. - Under Answer, enter the following answer:
- Expand the Advanced section and navigate to the Elicit Response section.
- For Elicit Response: ResponseBot Hook, enter
QNAFreeText
. - For Elicit Response: Response Session Attribute Namespace, enter
short_description
.
This creates a slot named short_description
that captures the response or description for the incident. This slot uses the built-in QNAFreeText, which is used for capturing free text.
- For Document Chaining: Chaining Rule, enter
QID::item.002
. This must be in single quotes. Remember this chaining rule to use when creating your document chain. - Leave the rest as default.
- Choose Create to save the question.
Create a document chain
Now we create a document chain in QnABot that will trigger the Lambda function to create a ticket and respond with a ticket number. Document chaining allows you to chain two bots based on the rule you configured. Complete the following steps:
- Choose Add to add a new question.
- Select qna.
- For Item ID, enter
item.002
. This should match the QID value given in the document chain rule earlier. - Under Questions/Utterances, enter
servicenow integration
. - Under Answer, enter the following answer:
- In the Advanced section, add the Lambda function ARN for Lambda Hook.
- Choose Create to save the question.
Test the QnABot
To test the QnABot default client, complete the following steps:
- Choose the options menu in the Content Designer and choose QnABot Client.
The QnABot client will open in a new browser tab.
- Log in using the newly created user credentials to begin the test.
If you plan to use the Amazon Lex Web UI on a static page, follow these instructions.
- Choose the chat icon at the bottom of the page to start the chat.
- To log in, choose Login on the menu.
You will be routed to the login page.
- Provide the
userId
created earlier. - For first-time logins, you will be prompted to reset your password.
- Now we can test the chatbot with example use cases. For our first use case, we want to learn about Amazon and enter the question “I want to learn about Amazon Lex, can you give me some information about it?” QnABot provides a video and some links to resources.
- In our next, example, we need to install software on our laptop, and ask “Can you give me instructions to install software.” QnABot understands that the user is requesting help installing software and provides answers from the knowledge bank. You can follow those instructions and install the software you need.
- While installing the software, what if you locked your password due to multiple failed login attempts? To request a password reset, you can ask “I need to reset my password.”
- You might need additional assistance resetting the password and want to create a ticket. In this case, enter “Please create a ticket.” QnABot asks for a description of the problem; you can enter “reset password.” QnAbot creates a ticket with the description provided and provides the ticket number as part of the response.
- You can verify the incident ticket was created on the ServiceNow console under Incidents. If the ticket is not shown on the first page, search for the ticket number using the search toolbar.
Clean up
To avoid incurring future charges, delete the resources you created. For instructions to uninstall the QnABot solution plugin, refer to Uninstall the solution.
Conclusion
Integrating QnABot on AWS with ServiceNow provides an end-to-end solution for automated customer support. With QnABot’s conversational ai capabilities to understand customer questions and ServiceNow’s robust incident management features, companies can streamline ticket creation and resolution. You can also extend this solution to show a list of tickets created by the user. For more information about incorporating these techniques into your bots, see QnABot on AWS.
About the Authors
Sujatha Dantuluri is a Senior Solutions Architect in the US federal civilian team at AWS. She has over 20 years of experience supporting commercial and federal government. She works closely with customers in building and architecting mission-critical solutions. She has also contributed to IEEE standards.
Maia Haile is a Solutions Architect at Amazon Web Services based in the Washington, D.C. area. In that role, she helps public sector customers achieve their mission objectives with well-architected solutions on AWS. She has 5 years of experience spanning nonprofit healthcare, media and entertainment, and retail. Her passion is using ai and ML to help public sector customers achieve their business and technical goals.