Skip to content
This repository has been archived by the owner on Aug 22, 2019. It is now read-only.

Better creation and handling of facebook buttons #1613

Merged
merged 9 commits into from Mar 19, 2019
Merged

Conversation

akelad
Copy link
Contributor

@akelad akelad commented Jan 21, 2019

So far quick reply buttons (e.g. for Facebook) can't really be used efficiently with rasa_core. Also Facebook buttons are forced to type postback, e.g. preventing Login buttons.

Proposed changes:

  • Added respective string representation for quick replies to channel.py, interactive.py and console.py similar to the button_to_string function
  • Changed the _add_postback_info function in facebook.py to only set button type to postback if button type is not specified by user
    Changes made by @smn-snkl

Status (please check what you already did):

  • made PR ready for code review
  • added some tests for the functionality
  • updated the documentation
  • updated the changelog

@codeclimate
Copy link

codeclimate bot commented Jan 21, 2019

Code Climate has analyzed commit 08afcce and detected 0 issues on this pull request.

View more on Code Climate.

@akelad
Copy link
Contributor Author

akelad commented Jan 21, 2019

@smn-snkl did you test whether this works? Because I'm just getting error messages from the fbmessenger library. If yes, how did you define the utterances in your domain file?

@tmbo tmbo modified the milestone: 0.13 release Jan 22, 2019
@smn-snkl
Copy link
Contributor

smn-snkl commented Jan 29, 2019

@akelad : I think I did back then. Are you sure this PR is right? I couldn't find the relevant lines in this PR:

channel_utter_action = "{}.{}".format(output_channel, utter_action)

        if channel_utter_action in self.templates:
            return np.random.choice(self.templates[channel_utter_action])

And I see you're trying to merge patch-2 into master. But in the original PR it's patch-1.

@smn-snkl
Copy link
Contributor

Oh, sorry. I mixed up these two PRs. Let me check what's going on here.

@smn-snkl
Copy link
Contributor

@akelad : Just verified it's working for me. I'm specifying the buttons according to the Messenger API (this)

For example, this is what I have in my domain file:

utter_help.quick_replies:
  - text: "How can I help?"
    quick_replies:
      - content_type: "text"
        title: "Search"
        payload: "/search"

@smn-snkl
Copy link
Contributor

@akelad : Two more things though.

  1. I think it would be useful to modify this section here in the dispatcher to include the quick_replies as well:
def utter_response(self, message: Dict[Text, Any]) -> None:
        """Send a message to the client."""

        bot_message = BotMessage(text=message.get("text"),
                                 data={"elements": message.get("elements"),
                                       "buttons": message.get("buttons"),
                                       "quick_replies": message.get("quick_replies"),  # does this work?
                                       "attachment": message.get("image")})

        self.latest_bot_messages.append(bot_message)
        self.output_channel.send_response(self.sender_id, message)
  1. If you think it would be useful, we might want to rename content_type to just type to be more generic and avoid confusion with other platforms

What do you think?

@akelad
Copy link
Contributor Author

akelad commented Feb 1, 2019

@tmbo what do you think about adding that stuff to the dispatcher? Not sure if it's not a bit too facebook specific

@smn-snkl
Copy link
Contributor

smn-snkl commented Feb 4, 2019

Maybe we can think of a more generic naming. Most platforms however, support some form of reply suggestions, e.g. Facebook's quick replies, Google's suggestion chips, Telegram's Reply Keyboard Markup

So some supported format for quick replies in the domain.yml would be super helpful, especially with #1471. Then you could also do something like:

facebook.utter_help:
  - text: "How can I help?"
    quick_replies:
      - content_type: "text"
        title: "Search"
        payload: "/search"
google.utter_help:
  - text: "How can I help?"
    quick_replies:
      - title: "Search"

@tmbo tmbo changed the title Smn snkl patch 2 Better creation and handling of facebook buttons Mar 6, 2019
@tmbo
Copy link
Member

tmbo commented Mar 19, 2019

Thanks a lot for the added facebook feature 👍 - I'll merge it as it is now, we'll need to refactor the input/output channels a bit more in the coming weeks and we can come up with a better name then

@tmbo tmbo merged commit 4edc288 into master Mar 19, 2019
@tmbo tmbo deleted the smn-snkl-patch-2 branch March 19, 2019 14:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants