def build_slack_message(integration, title, title_link, fallback_text, fields,
                        pre_text, body, color, thumb_url, image_url):
    """Build message using Slack webhook format.

    This will build the payload data for HTTP requests to services such as
    Slack, Mattermost and Discord.

    Args:
        integration (BaseChatIntegration):
            The Integration.

        title (unicode):
            The title for the message.

        title_link (unicode):
            The link for the title of the message.

        fallback_text (unicode):
            The non-rich fallback text to display in the chat, for use in
            IRC and other services.

        fields (dict):
            The fields comprising the rich message to display in chat.

        pre_text (unicode):
            Text to display before the rest of the message.

        body (unicode):
            The body of the message.

        color (unicode):
            A Slack color string or RGB hex value for the message.

        thumb_url (unicode):
            URL of an image to show on the side of the message.

        image_url (unicode):
            URL of an image to show in the message.

    Returns:
        dict:
        The payload of the Slack message request.
    """
    if not color:
        color = integration.DEFAULT_COLOR

    attachment = {
        'color': color or integration.DEFAULT_COLOR,
        'fallback': fallback_text,
        'title': title,
        'title_link': title_link,
        'text': body,
        'pretext': pre_text,
    }

    if fields:
        attachment['fields'] = fields

    if thumb_url:
        attachment['thumb_url'] = thumb_url

    if image_url:
        attachment['image_url'] = image_url

    return {
        'attachments': [attachment],
        'icon_url': integration.LOGO_URL,
    }