ServiceNow


Message Delivery

We've built a "Script Include" that you can add to your ServiceNow instance to make it possible to use the Moveworks API in just two lines of code!

  1. Install the Update Set Below
  1. Add your API key to your system properties (moveworks.api.bearer_auth_token)
  2. Use it anywhere you have GlideScript.
Copy
Copied
var client = new global.MoveworksApiSdk();
client.send_message(['example@moveworks.ai'], 'Hello world');
  1. To take advantage of the Message API using Flow Designer, install our supplemental Update Set.
ServiceNow Flow Designer

Smart Links & iFraming

Tutorial Video Coming Soon
  1. Add a customer response header to your sys_response_header table that matches the following. This allows portal pages to be rendered inside Microsoft Teams
ServiceNow iFrame Header
  1. Create a new UI Page in your Service Portal
  2. Build a widget which triggers either onload, or after collecting some information
Widget HTMLClientServer
Copy
Copied
<div class="panel panel-body">
    <h3> Send Messages via Bot </h3>
    <form class="form-group">
        <label for="field1">Recipients (Comma Separated)</label>
        <input class="form-control" ng-model="data.field1" id="field1" name="field1">

        <label for="field2">Message to send</label>
        <input class="form-control" ng-model="data.field2" id="field2" name="field2">
    </form>

    <button class="btn btn-primary pull-right" ng-click="c.send()">Send Message</button>
    <div>
        <p>
            {{data.status_code}}
            {{data.body}}
            {{data.response}}
        </p>
    </div>
</div>
Copy
Copied
api.controller=function() {
  /* widget controller */
	function getParmVal(name){
        var url = document.URL.parseQuery();
        if(url[name]) {
            return decodeURI(url[name]);
        } else {
            return;
        }
	}
	
    var c = this;
    c.onload = function() {
		c.server.update();
	}
	
	c.send = function() {
		c.server.update();
	}	
};
Copy
Copied
(function() {
  /* populate the 'data' object */
  /* e.g., data.table = $sp.getValue('table'); */
	var client = new global.MoveworksApiSdk();
	var recipients = input.field1.split(",");
	var message = input.field2;
	
	if (!recipients) {
		recipients = ['amerchia@moveworks.ai']
	}
	if (!message) {
		var defaultMessage = $sp.getParameter('default_message');
		if (defaultMessage) {
			message = defaultMessage
		} else {
			message = 'This is the default message'			
		}
	}
	
	var response = client.send_message(recipients, message);
	data.status_code = response.getStatusCode();
	data.body = response.getBody();
	data.response = JSON.stringify(response)
})();
Note: When the onload function is called, it triggers the server script function to run in its ENTIRETY. You can use this to trigger an action whenever a user navigates to this link.
  1. Add the widget to your UI Page