Name

sn_oe_sfs.VACommonActionAdapter

Description

No description available

Script

var VACommonActionAdapter = Class.create();
VACommonActionAdapter.prototype = {
  initialize: function(adapter, inputBuilder) {
      this.adapter = adapter;
      this.inputBuilder = inputBuilder;
      this.logger = new sn_oe_sfs.VACommonLogger(this.inputBuilder.getChannelLogger(), 'VACommonActionAdapter');
      this.logger.debug("VACommonActionAdapter channel: " + JSON.stringify(this.adapter) + " \n inputs: " + JSON.stringify(inputBuilder));
  },

  transform: function() {
      try {
          var richControl = this.inputBuilder.getRichControl();
          var payload = this.inputBuilder.getPayload();
          var actionType = richControl.type;
          var result = null;

          switch (actionType) {
              case 'Separator':
                  break;
              case 'StartSpinner':
                  var message = richControl.message;
                  var spinnerWaitTime = richControl.spinnerWaitTime;
                  var spinnerType = richControl.spinnerType;
                  if (!gs.nil(message)) {
                      if (spinnerType == 'processing') {
                          result = null;
                      } else if (spinnerType == 'wait_time') {
                          result = this.adapter.buildLiveAgentWaitTimeCard(payload, spinnerWaitTime, actionType);
                      } else {
                          result = this.adapter.getOutputTextCard(sn_cs.VASystemObject.getLeaveConversationMessage(), payload);
                      }
                  }
                  break;
              case 'EndSpinner':
                  if (richControl.spinnerType == 'wait_time') {
                      result = this.adapter.buildLiveAgentWaitTimeCard(payload, null, actionType);
                  }
                  break;
              case 'System':
                  var message = richControl.message;
                  if (!gs.nil(message)) {
                      result = this.adapter.getOutputTextCard(message, payload);
                  }
                  break;
              case 'StartTypingIndicatorActionMsg':
                  result = this.adapter.getStartTypingIndicatorMessage(payload);
                  break;
              case 'TopicFinished':
                  this.adapter.handleTopicFinished(payload);
                  break;
              default:
                  break;
          }
          return result;
      } catch (e) {
          this.logger.error("Error in default action outbound transformer : " + e.message);
          throw e;
      }
  },

  type: 'VACommonActionAdapter'
};

Sys ID

1f3a1ba6533201101c1addeeff7b12f8

Offical Documentation

Official Docs: