import json


def quick_reply(title, payload, image_url=None):
    """
    Creates a dict to use with send_text
    :param title: The title of the quick reply
    :param payload: The payload
    :param image_url: The image url (optional)
    :return: dict
    """
    if isinstance(payload, (dict, list)):
        payload = json.dumps(payload)

    payload_ = {
        'content_type': 'text',
        'title': title,
        'payload': payload,
      }

    if image_url:
        payload_['image_url'] = image_url

    return payload_