docs: def updateEmotionTone(user, emotionTone, maintainHistory):
      """
      updateEmotionTone updates the user emotion tone with the primary emotion -
      the emotion tone that has a score greater than or equal to the
      EMOTION_SCORE_THRESHOLD; otherwise primary emotion will be 'neutral'
      @param user a json object representing user information (tone) to be used in
      conversing with the Conversation Service
      @param emotionTone a json object containing the emotion tones in the payload
      returned by the Tone Analyzer
      """
      maxScore = 0.0
      primaryEmotion = None
      primaryEmotionScore = None
  
      for tone in emotionTone['tones']:
          if tone['score'] > maxScore:
              maxScore = tone['score']
              primaryEmotion = tone['tone_name'].lower()
              primaryEmotionScore = tone['score']
  
      if maxScore <= PRIMARY_EMOTION_SCORE_THRESHOLD:
          primaryEmotion = 'neutral'
          primaryEmotionScore = None
  
      # update user emotion tone
      user['tone']['emotion']['current'] = primaryEmotion
  
      if maintainHistory:
          if 'history' not in user['tone']['emotion']:
              user['tone']['emotion']['history'] = []
              user['tone']['emotion']['history'].append({
                  'tone_name': primaryEmotion,
                  'score': primaryEmotionScore
              })