Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Quick replies #342

Merged
merged 15 commits into from
Jan 31, 2019
Merged

[Feature] Quick replies #342

merged 15 commits into from
Jan 31, 2019

Conversation

kapi2289
Copy link
Contributor

@kapi2289 kapi2289 commented Sep 24, 2018

Description

Added

  • New QuickReplyText, QuickReplyLocation, QuickReplyEmail, QuickReplyPhoneNumber models
  • quick_replies attribute of Message model
  • Sending quick replies with send method

Examples

You can send quick replies with text only:

message = Message(text="Do you like me?", quick_replies=[QuickReplyText(title="Yes!"), QuickReplyText(title="No")])
client.send(message)

Example
or with images:

message = Message(text="Do you like me?", quick_replies=[QuickReplyText(title="Yes!", image_url="https://example.com/image1.jpg"), QuickReplyText(title="No", image_url="https://example.com/image2.jpg")])
client.send(message)

Example
You can use payload and data attributes to send some data.
If you want to response for quick reply just do this:

import random
msg = client.fetchThreadMessages()[0]
if msg.quick_replies:
    reply = random.choice(msg.quick_replies) # Choose a random quick reply
    client.quickReply(reply)

@madsmtm
Copy link
Member

madsmtm commented Sep 27, 2018

Looks amazing (!!!), you talked about adding special quick replies, that asks for the users phone number, email, or location, and I think you should add that first (even though it doesn't work on mobile (yet 😉 ))

I think it'd be nice to have a helper method, to reply to a quick reply

Also, the text you wrote above would be nice to have in the examples

@kapi2289 kapi2289 force-pushed the quick_replies branch 2 times, most recently from 2c29b62 to 492465a Compare December 8, 2018 23:30
Copy link
Member

@madsmtm madsmtm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need for the type attribute on the models, but otherwise, it looks close to ready 🎉

Copy link
Member

@madsmtm madsmtm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few isinstance checks instead, and then it's good!

@madsmtm madsmtm self-assigned this Jan 31, 2019
@madsmtm madsmtm merged commit b1a02ad into fbchat-dev:master Jan 31, 2019
@madsmtm
Copy link
Member

madsmtm commented Jan 31, 2019

I went ahead and fixed the small issues, thanks a lot for your hard work! 🎉

@kapi2289 kapi2289 deleted the quick_replies branch March 23, 2019 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants