Script Choice Module - Script Testing

Script Choice Module

The Script Choice, or Evaluate JavaScript pipeline activity evaluates custom JavaScript, and can be inserted anywhere in a pipeline.

Accessing Session Metadata Through JSON

All of a sessions metadata properties can be accessed through JavaScript using the following format: sessionMetaData.<Metadata Variable>.

Default session metadata properties represented in JSON can be seen below.

Examples of Accessing Metadata Properties

Get Guest question:

sessionMetaData.Guest.Question

Get Guest Name:

sessionMetaData.Guest.Name

Get Session ID:

sessionMetaData.Session.SessionId

Default Session Metadata Properties Represented as JSON

 "Guest": {
        "Name": "John Doe",
        "Id": "dl_vBFbdIv1Y0aPMOsabBBC9Q@30ce8ae3-4ac8-4a25-b2e3-a313841a625d",
        "Question": "I am unable to access Hardware Access Center for laptop replacement",
        "Locale": "en-US",
        "ChannelId": "directline",
        "GivenName": "John",
        "Surname": "Doe",
        "TenantName": "Instant"
    },
    "Session": {
        "SessionId": "a5d1fe78-d954-47bd-b196-ba4ac5da15d0",
        "StartedUtc": "2022-09-26T10:47:53.7976577+00:00",
        "ChatID": "6btnBr9ATyp5a4onmInj1D-us",
        "ReferrerUrl": "https://chime5-entrybot.azurewebsites.net/admin",
        "CurrentPipelineStage": {
            "Name": "chatend",
            "Type": "SendTextState"
        },
        "PipelinePath": [
            {
                "ToState": "start",
                "ToStateType": "SendTextState",
                "FromState": "StartChat",
                "Timestamp": "2022-09-26T10:47:59.2284505+00:00"
            },
            {
                "ToState": "azurelookup",
                "ToStateType": "KeyPhraseExtractionState",
                "FromState": "start",
                "FromStateType": "SendTextState",
                "Timestamp": "2022-09-26T10:48:02.8726515+00:00"
            },
            {
                "ToState": "chatend",
                "ToStateType": "SendTextState",
                "FromState": "azurelookup",
                "FromStateType": "KeyPhraseExtractionState",
                "Timestamp": "2022-09-26T10:48:23.4607605+00:00"
            }
        ],
        "SkillTagList": [],
        "AverageWaitTime": {
            "String": "0:00:00",
            "Seconds": 0,
            "Minutes": 0,
            "TotalSeconds": 0,
            "TotalMinutes": 0
        },
        "AverageWaitTimeLastHour": {
            "String": "0:00:00",
            "Seconds": 0,
            "Minutes": 0,
            "TotalSeconds": 0,
            "TotalMinutes": 0
        }
    },
    "clientActivityID": "1664189273805oy691xusb5",
    "azurelookup_language": "English",
    "azurelookup_keywords": "hardware,access,center,laptop",
    "azurelookup_entities": "hardware, laptop",
    "System": {
        "CurrentTimeUTC": "2022-09-26T10:48:24.7578914Z",
        "BaseUrl": "https://chime5-entrybot.azurewebsites.net",
        "Tenant": "ChimeV5",
        "PipelineName": "Azure Keyword Extraction Sample",
        "MediaUrl": "https://chime5-entrybot.azurewebsites.net/media/"
    }
}

Script Method - sendReply

This method sends a chat message to the guest sendReply('message')

Script Method - updateSessionMetaData

This method updates or adds session metadata properties updateSessionMetaData('Key', 'Value')

Script Method - createContent

This method creates a content item in Orchard createContent('ContentType', 'Publish':true|false, {'Content-Properties-As-JSON'})

Example of create content script method:

createContent('EvalRegistration', true, {"DisplayText": "Eval: Form Script, jdoe@domain", "EvalRegistration": {},"TitlePart": {"Title": "Eval: John Doe, jdoe@domain"}})

The JSON Structure of any existing content can be veiwed under the "actions" dropdown of the content item.

Only the following fields need to be included when creating a content item:

{  
  "DisplayText": "Eval: Form Script - Vivek, vgarg@outlook.com",
  "EvalRegistration": {},
  "TitlePart": {
    "Title": "Eval: VG TEST - VG, vgarg@outlook.com"
  }
}

Script Methods For Ticketing Integration

How to use pipeline action: Evaluate JavaScript for accessing ServiceNow Tickets?

How to use pipeline action: Evaluate JavaScript for accessing JIRA Tickets?

Elevating Service Desk Customer Support with Service-Now Ticketing Integration

Streamline Service Desk Support Operations with JIRA Ticketing Integration

Elevating Service Desk Customer Support with Cherwell Ticketing Integration

Script Methods For AI Summarization

How to use pipeline action: Evaluate JavaScript AI summary commands

Script Editor Enviroment

To assist with script writing, an enviroment has been created with example JSON session Metadata. This enviroment can be accessed from this link.

As changes are made to the script, result and errors are available in real time for review:

Errors are shown in real time:

pipeline, javascript
vgarg