jcraneNYC
ServiceNow Employee
ServiceNow Employee

Hey everyone!

Using the awesome power of our ServiceNow platform combined with Amazon Echo skill kit APIs, I've created an Amazon Echo integration using ServiceNow.

If you were at Knowledge 16 you may have already seen this once before. This is a new and improved version building on the capabilities of K16.

If you're interested in Integrating ServiceNow with Amazon Echo, here is how to do it!

1. Create an Amazon Developer Account

This is a required step for integrating ServiceNow with Amazon Echo. The first thing that is needed is a Developer account on Amazon. These are free and easy to set up.

find_real_file.png

2. Create an Alexa Skill

Navigate to your Alexa Skill Kit and define an Alexa skill for your ServiceNow integration. Below are the minimum required fields when setting up your Alexa Skill to integrate with your instance. Follow the bolded headers below that align with tabs on your Alexa Skill.

Skill Information:

Give your skill a name, and an invocation name (the words that wakes up your skill)

Interaction Model:

This defines the words and Phrases that trigger interactions within your ServiceNow instance. For now, we can mostly leave this blank. Follow the screenshot below to set up a starter Interaction model.

find_real_file.png

Configuration:

Make sure these fields are set as they are in the screenshot. For the endpoint, make sure you set the endpoint to be https://YOURINSTANCENAME.service-now.com/api/x_snc_amazon_echo/alexa

find_real_file.png

SSL Certificate:

find_real_file.png

Test:

Make sure the skill is enabled.

find_real_file.png

The Publishing Information and Privacy tabs can be left blank.

3. Load the App

Now that the Alexa skill has been created, the app needs to be loaded onto your instance. There are a few ways to get the app.

        GitHub (Preferred😞 This will ensure you have the latest and greatest version and is the preferred method to get the app. GitHub - JonCraneNOW/SN_Echo_Integration: ServiceNow integration for Amazon Echo.

        Update set - Attached: Load this update set into your instance, preview and commit. The app will come with the update set.

             

When the app is loaded into your instance, you will see this Application Menu available:

find_real_file.png

4. Design your interaction model

The interaction model within Alexa and ServiceNow consists of Intents and Utterances.

        Utterances: These are spoken words to 'listen' for in your applicaiton. When an Utterance is heard, an Intent is executed against the endpoint.

        Intents: These contain the spoken data mapped to a phrase and are sent to the endpoint.

To design your intents within ServiceNow, navigate to All Intents, and click New. The below example reads off a list of outages when asked.

find_real_file.png

Intent API Reference:
Current - Fields available on the intent record.

Content - Data that was heard and passed back to the intent. For example, if you ask a user to describe the cause of their issue when creating an incident with Alexa, the spoken dialog would be sent as Content.

Attributes - Data and various flags to send along with a user session. For example, if a user wants to interact with a Request record (Hear the request, approve it, escalate it) you may wish to pass the request number as an attribute.

ER - EchoResponse object. This object contains methods used for building a response to send back to Amazon Alexa skills.

IntentUtils - This script can be modified to add your own Utility functions, such as string manipulation, frequently-used queries, etc.

Here's a sample Intent script to use. This will read off a welcome message when asked to "Open ServiceNow".

---

(function(current, content, attributes, ER, IntentUtils){

  ER.setOutputSpeech(current.output_speech_format, "Welcome to the ServiceNow Alexa app. What can I help you with? For a list of commands, say 'Help'.", "");

  ER.setEnd(current.intent_ends_session);

  result = ER.response; //Required

})(current, content, attributes, new EchoResponseBuilder(), new IntentUtils());

---

Other fields to set:

Intent Keyword: LaunchRequest

Output Speech Format: PlainText

Submit your Intent.

In the Related List for Phrases, add a few phrases that you would like your Alexa skill to map to this intent. Include as many phrases as you need. Keep in mind that people could ask to "Hear a list of outages" in several different ways, so you must account for these when setting up your skills.

find_real_file.png

The Phrase is what a user would ask Alexa to hear the output of the intent. Active determines whether this phrase is used. Primary is used for the portal that comes with the app. If no Phrase is set as primary, the portal displays the intent name.

The above step is not required for a "LaunchRequest" intent

5. Build the schema

After you have defined all of your intents, and their phrases, you are ready to add them to your Alexa skill and test them.

Navigate back to your list of intents. You will notice two buttons in the list for Generating Intent Schema dn Utterances. Clicking on each will give you a list of Intents (JSON-formatted) and Utterances you can use. These can simply be pasted into your Alexa Skill Interaction Model.

find_real_file.png

Go back to your Amazon Developer account, find your Alexa skill, and paste the Intent Schema and then the Utterances into your Interaction model. Save your Amazon skill.

For reference, here is what a sample Intent and Utterance Schema COULD look like:

IntentsUtterances

{

  "intents": [

      {

          "intent": "CreateIncidentIntro"

      },

      {

          "intent": "ServiceInterruptions"

      },

      {

          "intent": "CriticalVulnerabilities"

      },

      {

          "intent": "CriticalSecurityIncidents"

      },

      {

          "intent": "SecurityThreatStatus"

      },

      {

          "intent": "SecurityIncidents"

      },

      {

          "intent": "PortfolioStatus"

      },

      {

          "slots": [

              {

                  "name": "Description",

                  "type": "AMAZON.LITERAL"

              }

          ],

          "intent": "CreateIncident"

      },

      {

          "slots": [

              {

                  "name": "Name",

                  "type": "AMAZON.LITERAL"

              }

          ],

          "intent": "CreateIncidentGetName"

      },

      {

          "intent": "CheckStatus"

      },

      {

          "slots": [

              {

                  "name": "Number",

                  "type": "AMAZON.NUMBER"

              }

          ],

          "intent": "CheckStatusInc"

      },

      {

          "intent": "WhatsHappening"

      },

      {

          "intent": "WhatsHappeningOutages"

      },

      {

          "intent": "WhatsHappeningIncidents"

      },

      {

          "intent": "WhatsHappeningChanges"

      },

      {

          "intent": "MyRequests"

      },

      {

          "intent": "ThisWeeksChanges"

      },

      {

          "intent": "MyApprovals"

      },

      {

          "intent": "Help"

      },

      {

          "intent": "AMAZON.StopIntent"

      },

      {

          "intent": "AMAZON.HelpIntent"

      }

  ]

}

CreateIncidentIntro Create an incident

CreateIncidentIntro Create incident

ServiceInterruptions What are the service interruptions

ServiceInterruptions Are there service interruptions

ServiceInterruptions Are there any service interruptions

CriticalVulnerabilities Hear Vulnerable Items

CriticalVulnerabilities Hear the Vulnerable Items

CriticalVulnerabilities Hear Vulnerabilities

CriticalSecurityIncidents Critical security incidents

CriticalSecurityIncidents Hear the critical security incidents

CriticalSecurityIncidents Hear Critical Security Incidents

SecurityThreatStatus Hear the security threats

SecurityThreatStatus Hear Security Threats

SecurityThreatStatus Are there security threats

SecurityThreatStatus Are there any security threats

SecurityIncidents Hear Security Incidents

SecurityIncidents Security Incidents

SecurityIncidents Hear the Security Incidents

PortfolioStatus IT Operations Portfolio Status

PortfolioStatus Status of the IT Operations portfolio

PortfolioStatus Hear the status of the IT Operations Portfolio

PortfolioStatus Whats the status of the IT Operations Portfolio

CreateIncident my problem is {Generic issue description|Description}

CreateIncident my issue is {Genericissuedescription|Description}

CreateIncidentGetName my name is {John Smith|Name}

CheckStatus Check incident status

CheckStatus Check the status of an incident

CheckStatus Check an incident status

CheckStatus Incident status

CheckStatusInc I. N. C. {Number}

WhatsHappening Whats Happening

WhatsHappening Whats Happening Today

WhatsHappening Whats going on Today

WhatsHappeningOutages Hear Outages

WhatsHappeningOutages Hear the Outages

WhatsHappeningIncidents Hear Incidents

WhatsHappeningIncidents Hear the Incidents

WhatsHappeningChanges Hear Changes

WhatsHappeningChanges Hear the Changes

MyRequests My requests

ThisWeeksChanges This weeks changes

ThisWeeksChanges Changes this week

Help help

AMAZON.StopIntent nevermind

AMAZON.StopIntent Nevermind

AMAZON.StopIntent never mind

AMAZON.StopIntent cancel

AMAZON.StopIntent stop

6. Try it out!

Ask Alexa to "Open ServiceNow". You should hear a friendly message!

If you get an error, make sure you have an Utterance that maps to an Intent in your Alexa Skill. Then, make sure you have an Intent defined in ServiceNow with Phrases for that intent. Finally, make sure your script is free of errors.

Other important stuff!

Script Includes:

IncludesPurpose
EchoConversationUsed for showing a Conversation in the Echo Service Portal. Primarily for demo purposes.
EchoLogLogs data in the Log table. Logs are tied to a session. Each Session has an inbound and outbound log activity.
EchoPortalUtilsPortal stuff. Add your own portal functions here if you would like to extend that capability.
EchoRequest

Called from the Scripted REST API. This is the primary Class that handles requests, processes intent records and returns a response.

EchoResponseBuilder

The Method for building Echo responses. The following functions can be used to construct a response:

setAttributes(obj)

setOutputSpeech(type String, text String, ssml String)

setCard(type String, title String, content Obj, text String, imageObj Obj)

setReprompt(type String, text String, ssml String)

setEnd(endSession String)

getResponse()

EchoSkillDataGeneratorUsed for generating Intent and Utterance schemas from the Intent list
IntentUtilA Utility class for performing various functions such as string manipulation, date/time manipulation, or anything else. Add custom functions here.

Documentation:

In the event that you hit a roadblock with your skill, consult the thorough Amazon documentation here!

Alexa Skills Kit Custom Interaction Model Reference - Amazon Apps & Services Developer Portal

Speech Synthesis Markup Language (SSML) Reference - Amazon Apps & Services Developer Portal

Define the Interaction Model in JSON and Text - Amazon Apps & Services Developer Portal

** IMPORTANT NOTE **

If you import the attached update set and see problems when you preview, you can SKIP them. This is because some of the functionality I used for the Knowledge 17 demo references data in tables that may not be enabled in your instance! These preview problems can be ignored.

Enjoy!!

Comments
darius_koohmare
ServiceNow Employee
ServiceNow Employee

This is great Jon! Thanks for sharing.


Grant Hulbert
ServiceNow Employee
ServiceNow Employee

Fantastic tutorial, Jon!



I'd love to use the GitHub option, but I get this error message during import into Studio on Helsinki: "The user only has read access to the repo. Make sure the user has both read and write access"



Edit: Jon reminded me that I need to fork into my own GitHub account, which solves the read/write access to repo issue. Thanks, Jon!


Doug Bagley
ServiceNow Employee
ServiceNow Employee

Thanks for posting this is great stuff. First question of many that are running through my head. I have it working with your intents and utterences. How does Alexa know who I am in ServiceNow instance? Is there an account configuration in Alexa to enter a ServiceNow id?



thanks! Doug


karlroberts
Kilo Explorer

Bit of a newby to ServiceNow!   When you set this up, and a client wants to get info on their status what is the relationship link with service now particularly in a multi-client service.     What identifies that organisation and where is this set to ensure they get the incidents and status' relevant to them.  



Sorry for the muppet question! XD



Cheers All



      Karl


vijay0610
Kilo Explorer

Hi All,


                  Above steps are worked well before but now while testing in Amazon Developer Console , While enter the Invocation name it is not redirecting to "LaunchRequest" it redirects to "ThisWeeksChanges" IntentRequest , Kindly someone help me..


Rohit95
Kilo Contributor

How do i get my user name like below for MyRequests intent. I need to know how it will take the data for my requests.

var usr = 'f7c7610d13b69200d0143d622244b053'; //For demo purposes

howardrichter
Mega Expert

I was wondering about security. That is what user account does the integration use to query the SN system?

Shea Laughlin
Kilo Contributor

Just about to start playing around with this however, I've noticed that the Amazon UI has changed and some of the instructions don't match up 1:1.  Before digging in too deep, are the instructions and update set still applicable and working in the new Amazon UI and Kingston?

Shea Laughlin
Kilo Contributor

Has anyone been able to get the update set to work with Kingston?  I get the welcome message but thats it.  Nothing else seems to work...

Mikael at Advan
Tera Contributor
Hi Shea, Yes, i’ve made a fork with updates that you can use.
Shea Laughlin
Kilo Contributor

Awesome!  Where might I find that?

Mikael at Advan
Tera Contributor

https://github.com/mihed001/SN_Echo_Integration
I could also share Alexa config if you send med an email (mikael.hedlund@advania.se).

Subhrajit2
Giga Contributor

I know this is very old post but it is most relevant to my question, so posting it here.

 

How do I use dialog delegate directive to delegate a dialog to Alexa (for confirmation, acknowledgement etc. ) using this design (intent records and associated script).

 

I do not want to create multiple intents to handle the dialog flow ( like create incident (get intro/name), create incident (get issue), create incident ).

I am looking for a way to delegate the dialog to Alexa so that I can get all answers in the same intent.

 

Any input to this will really be helpful.

 

Regards,
Subhrajit

Vijayanand Dhan
Tera Contributor

Hi Subhrajit,

Did you find the answer by any chance? I am searching out for the same - 'delegate the dialog to Alexa'

Vijayanand Dhan
Tera Contributor

Hi Subhrajit,

Did you find the answer by any chance? I am searching out for the same - 'delegate the dialog to Alexa'

howardrichter
Mega Expert

Still trying to see how to give access via users accounts/roles.

lukasz_piech
Kilo Explorer

Hi 

Realize this is an old post, but did anyone got the servicenow account impresonation figured out?

howardrichter
Mega Expert

I was looking for any updates as well. My issue/question is how to tie this integration to an account.  For example if Rick Blaine uses his Alexa account, how can that be tied to his Rick Blaine account in ServiceNow. Then if Victor Laszlo uses his Alexa account how can that be tied to his ServiceNow account?

lukasz_piech
Kilo Explorer

So it all boils down to account linking. I know an alternative approach to alexa (try googling serviceNow amazon echo - its there are 2 valuable results - the one we comment now and another one) that implements account linking but uses AWS lambda as proxy. It is doing exactly what we need but - i have already invested some time in THIS solution and would not want to redirect to a different approach, especially since i find this solution really really good

Hamesh
Kilo Explorer

Hi Jcrane,

 

            Thank you so much for this content. I was able to integrate Alexa and Service Now following the mentioned steps (2/19/2019)

 

ServiceNow Kingston 

 

Regards,

Shankar

Revanth7
Tera Contributor

Hi Hamesh,

 

Could you please help me with the integration into the kingston version or above.

 

Thanks,

Arockia

Hamesh
Kilo Explorer

Please let me know, if you need my help, if you face any specific issue, let me know the same. I can help you.

Version history
Last update:
‎05-03-2017 11:46 AM
Updated by: