Detecting facebook with get_latest_input_channel

Hi, I’m using get_latest_input_channel to determine we’re dealing with a Facebook connection. I have a message immediately after ‘greet’ that prompts with buttons/quick replies.

At the end, the story prompts for another run through and performs a ‘action_restart’ followed by ‘greet’ to start at the top again if required.

The first run through, I see that ‘tracker.get_latest_input_channel()’ is set to facebook and my quick replies work correctly. However, on the 2nd pass, ‘tracker.get_latest_input_channel()’ is set to None immediately after ‘greet’, for the first set of quick replies, but correctly sets to ‘facebook’ later in the story.

Should I be doing something else at the restart point to ensure input_channel is set correctly from the outset?

Thanks.

@drod what do you mean with “the story prompts for another run through” - could you show me what your stories look like?

Hi @akelad, thanks for getting back. I have the following story; the user is prompted to see if they want to start over again via ‘action_another_appt’

  • greet

    • action_greet_user
    • action_what_service

    …steps removed for clarity…

    • action_another_appt
  • startover

    • action_reset

This calls ‘action_reset’ as follows:

class ActionReset(Action): def name(self): return “action_reset”

  def run(self, dispatcher, tracker, domain):
     PERSON = tracker.get_slot('PERSON')
     return [Restarted(),
             UserUttered(text="/greet", parse_data={
                   "intent": {"confidence": 1.0, "name": "greet"},
                   "entities": []
                  }),
             FollowupAction(name="action_greet_user"),
             SlotSet("PERSON", PERSON)]

‘action_what_service’ is called after ‘greet’ and is as follows:

class ActionWhatService(Action): def name(self) -> Text: return “action_what_service”

  def run(self, dispatcher, tracker, domain):
      logger.debug("input channel is {}".format(tracker.get_latest_input_channel()))

You can see this output the channel type; looking at the debug logs I see the following:

Initial pass on bot start…

2020-03-09 15:52:44 DEBUG actions.actions - greet name is None

2020-03-09 15:52:44 DEBUG rasa_sdk.executor - Finished running ‘action_greet_user’

2020-03-09 15:52:45 DEBUG rasa_sdk.executor - Received request to run ‘action_what_service’

2020-03-09 15:52:45 DEBUG actions.actions - input channel is facebook

2020-03-09 15:52:45 DEBUG rasa_sdk.executor - Finished running ‘action_what_service’

After selecting that we want to ‘start over again’…

2020-03-09 15:54:12 DEBUG actions.actions - greet name is David

2020-03-09 15:54:12 DEBUG rasa_sdk.executor - Finished running ‘action_greet_user’

2020-03-09 15:54:14 DEBUG rasa_sdk.executor - Received request to run ‘action_what_service’

2020-03-09 15:54:14 DEBUG actions.actions - input channel is None

2020-03-09 15:54:14 DEBUG rasa_sdk.executor - Finished running ‘action_what_service’

Thanks, David

Hi @drod,

When you create the instance of UserUttered in ActionReset.run(), try passing a value for input_channel as well. You could try specifying input_channel=tracker.get_latest_input_channel().

Then, the next time you use tracker.get_latest_input_channel() it will look at the latest UserUttered event in the tracker (the one you created manually) and then extract the latest input channel property from there.

Hi @fede, thanks for getting back. I’ll give that a go and see if it fixes the problem. Thanks!

1 Like