---
sourceDocument: Australia Conversational Interfaces
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/pt-BR/conversational-interfaces

 Release :

    - australia

ft:locale :

    - pt-BR

ft:publication_title :

    - Australia Conversational Interfaces

ft:clusterId :

    - convint

bundleId :

    - convint

workflow :

    - Platform


---

# Transform Virtual Agent API request and response

# Transform Virtual Agent API request and response {#ariaid-title1}

* Versão de lançamento: Australia
* 
* Atualizado 12 de mar. de 2026
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 2 min. de leitura

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

## Antes de Iniciar

Role required: admin

## Procedimento

1. Navigate to AllSystem Extensions PointsScripted 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.
   {#transform-virtual-agent-api-request-and-response__ul_kdv_gqk_n1c}
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.


          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
              };
          },

      Figura 1. sn_va_as_service.va_api_payload_transformation extension point
   4. Click Update.
   {#transform-virtual-agent-api-request-and-response__substeps_g1w_pqk_n1c}
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.


          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'
          };

      Figura 2. sn_va_as_service.va_api_output_transformation extension point
   4. Click Update.
   {#transform-virtual-agent-api-request-and-response__substeps_bqw_rrk_n1c}

