Dialogue Cloud

How to connect Service Now in Dialogue Studio

Introduction

In this guide will show you how you connect to Service Now for your self-service bot. This can be implemented as a chat-bot, by using a chat based application. For example the Anywhere365 WebChat, Microsoft Teams or Skype for Business. This can also be implemented as a voice bot by using the transcription.

This scenario can be used as a followup for of the Connect with DialogFlow scenario, Learn More

Prerequisites

For this scenario the following point must be done first:

Configuration Lookup Incident

In this example we will be looking up a incident based on the incident number. Based on what kind of bot your are using the configuration can be different.

(Optional) Handle both channels (chat/voice)

When using both channels, you need to split up the flow based on channel. This is done using a Switch node.

Steps:

  1. Drag and drop a Switch Node

  2. Open Node

    1. Change Property to msg.session.type

    2. Add an option for the chat channel

      == Chat

    3. Add the option otherwise for audio/video

  3. Connect end of the Say node to begin of the Switch Node

You can now continue with both the interactions below. Connect option 1 to the Chat-bot interaction, connect the otherwise option to the Voice-bot interaction.

Voice-bot

For the Voice-bot we will use DTMF tones, this is done with the ask and wait node:

Steps:

  1. Drag and drop the Ask and Wait node

  2. Open the node

    1. Set the text to: "Please enter your incident number and finish with the # key."

    2. Change the Wait for to "Specific Tone"

    3. Set the tone to "#"

  3. Connect end of previous node to begin of the Ask and Wait node.

Next we need to store the output, so we can use it later. This is done with a Change node.

Steps:

  1. Drag and drop a Change node

  2. Open Node

    1. Create a rules

      1. Set: msg.incidentnumber

        to: msg.payload.dtmf

  3. Connect end of the Ask and Wait node with begin of the Change node

Chat-bot

For the Chat-bot we need to listen to the customers chat message. This is done using a Wait for Chat node.

Steps:

  1. Drag and drop a Wait for Chat node

  2. Connect end of the Say node (or option 1 of the switch node) with begin of the Wait for Chat node

Next we need to store the output, so we can use it later. This is done with a Change node.

Steps:

  1. Drag and drop a Change node

  2. Open Node

    1. Create a rules

      1. Set: msg.incidentnumber

        to: msg.payload

  3. Connect end of the Wait for Chat node with begin of the Change node

 

Send request to Service Now

Now that we have the incident number we can send our request. First we need to make the package for the request, this is done with a Function node.

Steps:

  1. Drag and drop a Function Node

  2. Open Node

    1. Fill in the following function:

      Note: You can also pass the authentication in Base64 format as a header.

      "Authorization": "Basic [Encrypted credentials]"

      Copy
      Function
      msg.headers = {
      "Accept": "application/json"
      };
      return msg;
  3. Connect the output of the previous node to the begin of the Function node.

Now that we have a message set, we can send it to Service Now. This is done with a HTTP Request Node.

Steps:

  1. Drag and drop a http request node

  2. Open Node:

    1. Method = GET

    2. URL = https://[tenant].service-now.com/api/now/table/incident?sysparm_query=numberENDSWITH{{{incidentnumber}}}

      Note: Replace the tenant, with your own tenant.
    3. Enable Use Authentication

      1. Set type to Basis Authentication
      2. Enter the username of the ServiceNow service account
      3. Enter the password of the ServiceNow service account
    4. Return = a parsed JSON object

  3. Connect the end of the Function node to the begin of the HTTP request node.

Handle response

Service Now will send back a JSON with the results. First we need to verify if we have had any results. This is done using a Switch node.

Steps:

  1. Drag and drop a Switch Node

  2. Open Node

    1. Change Property to msg.payload.result[0]

    2. Add an option to see if there is a result.

      is not null

    3. Add the option otherwise for no results.

  3. Connect end of the HTTP request node to begin of the Switch Node

If results are found you can add a Say node to inform the customer. Optionally you can also loop back let the customer fill in another incident number.

Next we need to store the result so we can use it later. This is done using a Change node.

Steps:

  1. Drag and drop a Change node

  2. Open Node

    1. Create a rules

      Note: Feel free to use any property, below are examples.
      1. Set: msg.active

        to: msg.payload.result[0].active

      1. Set: msg.short_description

        to: msg.payload.result[0].short_description

      1. Set: msg.close_code

        to: msg.payload.result[0].close_code

      1. Set: msg.close_notes

        to: msg.payload.result[0].close_notes

  3. Connect end of the Wait for Chat node with begin of the Change node

Example uses of the information are:

  • Tell to the customer using Say node

  • Route the customer using a Switch node

  • Followup in ServiceNow with a new HTTP Request node

Configuration Create Incident

In this example we will be creating incident with an description. Based on what kind of bot your are using the configuration can be different.

(Optional) Handle both channels (chat/voice)

When using both channels, you need to split up the flow based on channel. This is done using a Switch node.

Steps:

  1. Drag and drop a Switch Node

  2. Open Node

    1. Change Property to msg.session.type

    2. Add an option for the chat channel

      == Chat

    3. Add the option otherwise for audio/video

  3. Connect end of the Say node to begin of the Switch Node

You can now continue with both the interactions below. Connect option 1 to the Chat-bot interaction, connect the otherwise option to the Voice-bot interaction.

Voice-bot

For the Voice-bot we want to listen to the customer. This can be done with the Transcriptor Node

Steps:

  1. Drag and drop a Transcriptor node

  2. Open Node

    1. Optional change the language of the node

  3. Connect the end of the Say node (or option otherwise of the switch node) with begin of the Transcriptor node.

By default the Transcriptor node will keep listening to the customer and restarting the flow. In this case we need to stop after the first output. This can be done stopping the transcriptor with a stop payload.

Steps:

  1. Drag and drop Change node

  2. Open Node

    1. Create rule

      1. Set: msg.payload.stop

        to: true (Boolean)

  3. Connect "events with transcriptor" end with begin of the Change node

  4. Connect end of the Change node with begin of the Transcriptor node

Next we need to store the output, so we can use it later. This is done with a Change node.

Steps:

  1. Drag and drop a Change node

  2. Open Node

    1. Create a rules

      1. Set: msg.description

        to: msg.payload.transcriptor.transcript

  3. Connect "events with transcriptor" end with begin of the Change node

Chat-bot

For the Chat-bot we need to listen to the customers chat message. This is done using a Wait for Chat node.

Steps:

  1. Drag and drop a Wait for Chat node

  2. Connect end of the Say node (or option 1 of the switch node) with begin of the Wait for Chat node

Next we need to store the output, so we can use it later. This is done with a Change node.

Steps:

  1. Drag and drop a Change node

  2. Open Node

    1. Create a rules

      1. Set: msg.description

        to: msg.payload

  3. Connect end of the Wait for Chat node with begin of the Change node

 

Send request to Service Now

Now that we have the description for the incident we can send our request. First we need to make the package for the request, this is done with a Function node. In this example we will be creating a incident with a description, of course you can also use other fields.

Steps:

  1. Drag and drop a Function Node

  2. Open Node

    1. Fill in the following function:

      Note: You can also pass the authentication in Base64 format as a header.

      "Authorization": "Basic [Encrypted credentials]"

      Copy
      Function
      msg.headers = {
      "Accept": "application/json"
      };
      msg.payload = {
      'short_description' : msg.description
      }
      return msg;
  3. Connect the output of the previous node to the begin of the Function node.

Now that we have a message set, we can send it to Service Now. This is done with a HTTP Request Node.

Steps:

  1. Drag and drop a http request node

  2. Open Node:

    1. Method = POST

    2. URL = https://[tenant].service-now.com/api/now/table/incident

      Note: Replace the tenant, with your own tenant.
    3. Enable Use Authentication

      1. Set type to Basis Authentication
      2. Enter the username of the ServiceNow service account
      3. Enter the password of the ServiceNow service account
    4. Return = a parsed JSON object

  3. Connect the end of the Function node to the begin of the HTTP request node.

Handle response

Service Now will send back a JSON with the results. We can store the result so we can use it later. This is done using a Change node.

Steps:

  1. Drag and drop a Change node

  2. Open Node

    1. Create a rules

      Note: Feel free to use any property, below are examples.
      1. Set: msg.number

        to: msg.payload.result.number

      1. Set: msg.short_description

        to: msg.payload.result.short_description

  3. Connect HTTP Request node with begin of the Change node

Example uses of the information are:

  • Tell to the customer using Say node

     Tip:

    Url can be generated with:

    Copy
    Url
    https://[tenant].service-now.com/nav_to.do?uri=incident.do?sys_id=" & payload.result.sys_id
  • Route the customer using a Switch node

  • Followup in ServiceNow with a new HTTP Request node