class_docstr: Filters response variations based on the channel, action and condition.
class_docstr_tok: ["Filters","response","variations","based","on","the","channel",",","action","and","condition","."]
docstr: Returns array of responses that fit the channel, action and condition.
docstr_tok: ["Returns","array","of","responses","that","fit","the","channel",",","action","and","condition","."]
code: def responses_for_utter_action(
      self,
      utter_action: Text,
      output_channel: Text,
      filled_slots: Dict[Text, Any],
  ) -> List[Dict[Text, Any]]:
      """Returns array of responses that fit the channel, action and condition."""
      # filter responses without a condition
      default_responses = list(
          filter(
              lambda x: (x.get(RESPONSE_CONDITION) is None),
              self.responses[utter_action],
          )
      )
      # filter responses with a condition that matches the filled slots
      conditional_responses = list(
          filter(
              lambda x: (
                  x.get(RESPONSE_CONDITION)
                  and self._matches_filled_slots(
                      filled_slots=filled_slots, response=x
                  )
              ),
              self.responses[utter_action],
          )
      )
  
      # filter conditional responses that match the channel
      conditional_channel = list(
          filter(
              lambda x: (x.get(CHANNEL) == output_channel),
              conditional_responses,
          )
      )
      # filter conditional responses that don't match the channel
      conditional_no_channel = list(
          filter(
              lambda x: (x.get(CHANNEL) is None), conditional_responses
          )
      )
      # filter default responses that match the channel
      default_channel = list(
          filter(
              lambda x: (x.get(CHANNEL) == output_channel),
              default_responses,
          )
      )
      # filter default responses that don't match the channel
      default_no_channel = list(
          filter(lambda x: (x.get(CHANNEL) is None), default_responses)
      )
  
      if conditional_channel:
          return conditional_channel
  
      if default_channel:
          return default_channel
  
      if conditional_no_channel:
          return conditional_no_channel
  
      return default_no_channel
  
file_path: rasa/rasa/core/nlg/generator.py
imports: import logging
  from typing import List, Optional, Union, Text, Any, Dict
  import rasa.shared.utils.common
  import rasa.shared.utils.io
  from rasa.shared.constants import CHANNEL, RESPONSE_CONDITION
  from rasa.shared.core.domain import Domain
  from rasa.utils.endpoints import EndpointConfig
  from rasa.shared.core.trackers import DialogueStateTracker
label_desc: Use image node_id 3 for calling the ResponseVariationFilter obj's underlying member method code with example usage: obj.responses_for_utter_action(utter_action, output_channel, filled_slots) and returns: default_no_channel, conditional_channel, default_channel, conditional_no_channel