Create a profile parser action for Apple Messages for Business
Release version: Washingtondc
Updated February 1, 2024
1 minute to read
Create an action to parse the user information response and find the corresponding user on the ServiceNow® instance for Conversational Integration with Apple Messages for Business using the information provided here.
Before you begin
Role required: admin
Procedure
Refer to the following procedure to create a new action. Create an action.
In the Flow Designer Integration Hub, set the Input field to response_body (string).
Figure 1. Flow designer example
You can use the following example script to help create your script for the action.
(function execute(inputs, outputs) {
try {
var profile = JSON.parse(inputs.response_body);
var email = profile[0]['profile']['email'];
var user_sys_id = "";
var result = {
"auth_success": false,
"user_sys_id": ""
};
if (email) {
result['auth_success'] = true;
var userGr = new GlideRecord("sys_user");
userGr.addQuery("email", email);
userGr.query();
if (userGr.getRowCount() == 1)
if (userGr.next())
user_sys_id = userGr.getUniqueValue();
result['user_sys_id'] = user_sys_id;
}
outputs.result = result;
} catch (e) {
gs.error("Error in Virtual Agent - Parse User Profile: " + e.message);
throw e;
}
})(inputs, outputs);
Set the Output field to the following:
result = {
"auth_success": false,
"user_sys_id": "1234"
};