function buildMessageDomElements(newPayload, isUser) {
    var textArray = isUser ? newPayload.input.text : newPayload.output.text;
    if (Object.prototype.toString.call(textArray) !== '[object Array]') {
      textArray = [textArray];
    }

    var responses = [];

    if (newPayload.hasOwnProperty('output')) {
      if (newPayload.output.hasOwnProperty('generic')) {

        var generic = newPayload.output.generic;

        generic.forEach(function (gen) {
          getResponse(responses, gen);
        });
      }
    } else if (newPayload.hasOwnProperty('input')) {
      var input = '';
      textArray.forEach(function (msg) {
        input += msg + ' ';
      });
      input = input.trim()
        .replace(/&/g, '&amp;')
        .replace(/</g, '&lt;')
        .replace(/>/g, '&gt;');

      if (input.length !== 0) {
        responses.push({
          type: 'text',
          innerhtml: input
        });
      }
    }
    return responses;
  }
// Constructs new generic elements from a message payload
Constructs new generic elements from a message payload
Constructs new generic elements from a message payload
function buildMessageDomElements(newPayload, isUser) {
    var textArray = isUser ? newPayload.input.text : newPayload.output.text;
    if (Object.prototype.toString.call(textArray) !== '[object Array]') {
      textArray = [textArray];
    }
    var responses = [];
    if (newPayload.hasOwnProperty('output')) {
      if (newPayload.output.hasOwnProperty('generic')) {
        var generic = newPayload.output.generic;
        generic.forEach(function (gen) {
          getResponse(responses, gen);
        });
      }
    } else if (newPayload.hasOwnProperty('input')) {
      var input = '';
      textArray.forEach(function (msg) {
        input += msg + ' ';
      });
      input = input.trim()
        .replace(/&/g, '&amp;')
        .replace(/</g, '&lt;')
        .replace(/>/g, '&gt;');
      if (input.length !== 0) {
        responses.push({
          type: 'text',
          innerhtml: input
        });
      }
    }
    return responses;
  }
function buildMessageDomElements ( newPayload , isUser ) { var textArray = isUser ? newPayload . input . text : newPayload . output . text ; if ( Object . prototype . toString . call ( textArray ) !== '[object Array]' ) { textArray = [ textArray ] ; } var responses = [ ] ; if ( newPayload . hasOwnProperty ( 'output' ) ) { if ( newPayload . output . hasOwnProperty ( 'generic' ) ) { var generic = newPayload . output . generic ; generic . forEach ( function ( gen ) { getResponse ( responses , gen ) ; } ) ; } } else if ( newPayload . hasOwnProperty ( 'input' ) ) { var input = '' ; textArray . forEach ( function ( msg ) { input += msg + ' ' ; } ) ; input = input . trim ( ) . replace ( / & / g , '&amp;' ) . replace ( / < / g , '&lt;' ) . replace ( / > / g , '&gt;' ) ; if ( input . length !== 0 ) { responses . push ( { type : 'text' , innerhtml : input } ) ; } } return responses ; }
Constructs new generic elements from a message payload
Constructs new generic elements from a message payload