def create_slack_payload(response_type='ephemeral', text="", attachments=None):
    """Create a Slack payload formatted correctly."""
    payload = {
        'statusCode': '200',
        'headers': {'Content-Type': 'application/json'},
        'response_type': response_type,
        'text': text
    }
    if attachments is not None:
        if isinstance(attachments, dict):
            attachments = [attachments]
        payload['attachments'] = attachments
    return payload