examples/assistant_tone_analyzer_integration/tone_detection.js
function invokeToneAsync(assistantPayload, toneAnalyzer) {
  return new Promise(function(resolve, reject) {
    toneAnalyzer.tone({ text: assistantPayload.input.text }, function(error, data) {
      if (error) {
        reject(error);
      } else {
        resolve(data);
      }
    });
  });
}
function invokeToneAsync(assistantPayload, toneAnalyzer) {
  return new Promise(function(resolve, reject) {
    toneAnalyzer.tone({ text: assistantPayload.input.text }, function(error, data) {
      if (error) {
        reject(error);
      } else {
        resolve(data);
      }
    });
  });
}
function invokeToneAsync ( assistantPayload , toneAnalyzer ) { return new Promise ( function ( resolve , reject ) { toneAnalyzer . tone ( { text : assistantPayload . input . text } , function ( error , data ) { if ( error ) { reject ( error ) ; } else { resolve ( data ) ; } } ) ; } ) ; }
invokeToneAsync is an asynchronous function that calls the Tone Analyzer service and returns a Promise
@param assistantPayload json object returned by the Watson Assistant Service
@param toneAnalyzer an instance of the Watson Tone Analyzer service
@return a Promise for the result of calling the toneAnalyzer with the assistantPayload
(which contains the user's input text)
invokeToneAsync is an asynchronous function that calls the Tone Analyzer service and returns a Promise