diff --git a/fbchat/client.py b/fbchat/client.py index 17587f9..3b6a7a5 100644 --- a/fbchat/client.py +++ b/fbchat/client.py @@ -1048,13 +1048,15 @@ class Client(object): if message.quick_replies: xmd = {"quick_replies": []} for quick_reply in message.quick_replies: - xmd["quick_replies"].append({ - "content_type": "text", - "title": quick_reply.title, - "payload": quick_reply.payload, - "image_url": quick_reply.image_url, - "data": quick_reply.data, - }) + q = dict() + q["content_type"] = quick_reply.type.value.lower() + q["payload"] = quick_reply.payload + q["data"] = quick_reply.data + if isinstance(quick_reply, QuickReplyText): q["title"] = quick_reply.title + if not isinstance(quick_reply, QuickReplyLocation): q["image_url"] = quick_reply.image_url + xmd["quick_replies"].append(q) + if len(message.quick_replies) == 1 and message.quick_replies[0].is_response: + xmd["quick_replies"] = xmd["quick_replies"][0] data['platform_xmd'] = json.dumps(xmd) return data diff --git a/fbchat/models.py b/fbchat/models.py index 4546453..3bcddc3 100644 --- a/fbchat/models.py +++ b/fbchat/models.py @@ -482,7 +482,7 @@ class QuickReplyText(QuickReply): class QuickReplyLocation(QuickReply): def __init__(self, **kwargs): - """Represents a location quick reply""" + """Represents a location quick reply (Doesn't work on mobile)""" super(QuickReplyLocation, self).__init__(_type=QuickReplyType.LOCATION, **kwargs) self.is_response = False @@ -491,7 +491,7 @@ class QuickReplyPhoneNumber(QuickReply): image_url = None def __init__(self, image_url=None, **kwargs): - """Represents a phone number quick reply""" + """Represents a phone number quick reply (Doesn't work on mobile)""" super(QuickReplyPhoneNumber, self).__init__(_type=QuickReplyType.PHONE_NUMBER, **kwargs) self.image_url = image_url @@ -500,7 +500,7 @@ class QuickReplyEmail(QuickReply): image_url = None def __init__(self, image_url=None, **kwargs): - """Represents an email quick reply""" + """Represents an email quick reply (Doesn't work on mobile)""" super(QuickReplyEmail, self).__init__(_type=QuickReplyType.EMAIL, **kwargs) self.image_url = image_url