Transform Virtual Agent API request and response

task australia Updated Sep 10, 2026 2 min read transform-virtual-agent-api-request-and-response.md
Raw file servicenow.com

You can transform Virtual Agent API request and response into supported formats through the scripted extension points provided in Virtual Agent API.

Before you begin

Role required: admin

Procedure

  1. Navigate to All > System Extensions Points > Scripted Extension Points

    • The sn_va_as_service.va_api_payload_transformation extension point transforms primary bot payload into standard Virtual Agent API supported format before processing the request. The sn_va_as_service.va_api_output_transformation extension point transforms Virtual Agent API response into a format supported by the primary bot.
    • Both the scripted extension points have two parameters: shouldTransform and transform. shouldTransform is used to determine whether the implementation is executed. transform is used to transform the request or response.
  2. If you want to transform the request payload, complete the following steps.

    1. Select sn_va_as_service.va_api_payload_transformation extension point

    2. In the Related Links section, click Create implementation.

    3. Update the extension point script as per your requirements.

      In sn_va_as_service.va_api_payload_transformation extension point, the request parameter is an object with two keys: payload and headers. payload is the request payload received from the primary bot, and headers are the headers sent in the request payload. The following is a sample implementation.

      JavaScript
      var va_api_payload_transformation = Class.create();va_api_payload_transformation.prototype = {    initialize: function() {},
          shouldTransform: function(request) {        return request.payload.caller === "examplebot";    },
          /*     return object for transform function should be in the following format    transformedRequest = {    payload: request.payload,    headers: request.headers    };    */transform: function(request) {    var payload = request.payload;    var headers = request.headers;
          var vaAPIPayload = {	"userId": payload.userId,	"emailId": payload.email,	"message": {	    "text": payload.message,	    "typed": true	},	"contextVariables": {	    "requester_session_language": payload.user_language	},	"appInboundId": "custom_1"    };	    return {	payload: vaAPIPayload,	headers: headers    };},

      [Omitted image "va-api-payload-transformation-extension-point.png"] Alt text: Scripted extension point for the transformation of request payload

    4. Click Update.

  3. If you want to transform the response payload, complete the following steps.

    1. Select sn_va_as_service.va_api_output_transformation extension point

    2. In the Related Links section, click Create implementation.

    3. Update the extension point script as per your requirements.

      In sn_va_as_service.va_api_output_transformation extension point, the response parameter is an object with two keys: inputPayload and responsePayload. inputPayload is the request payload received from Virtual Agent API, and responsePayload is the response from Virtual Agent API which you can use to build the transformed response. Use the appInboundId field of the request payload to determine whether to return true or false. The following is a sample implementation.

      JavaScript
      var va_api_output_transformation = Class.create();va_api_output_transformation.prototype = {    initialize: function() {},
          shouldTransform: function(response) {	return (response.inputPayload.appInboundId === 'custom_1');    },
          /*    input object param for transform function should be in the following format    response = {        inputPayload: response.inputPayload,	responsePayload: response.responsePayload    };    */    transform: function(response) {	//return only transformed payload        return {	    'custom_structure': response.responsePayload	};    },
          type: 'va_api_output_transformation'};

      [Omitted image "va-api-output-transformation-extension-point.png"] Alt text: Scripted extension point for the transformation of response payload

    4. Click Update.

Search documentation
Search document titles and file paths on the australia branch