def METHOD_NAME(event, messages, type_):
    message_dicts = []
    for sms in messages:
        error_message = None
        if event.status != MessagingEvent.STATUS_ERROR:
            status, error_message = get_sms_status_display_raw(sms)
        else:
            status = MessagingEvent.STATUS_SLUGS.get(event.status, "unknown")
        date_modified = sms.date_modified.isoformat() if sms.date_modified else None
        message_data = {
            "message_id": sms.id,
            "date": sms.date,
            "date_modified": date_modified,
            "type": type_,
            "direction": SMS.DIRECTION_SLUGS.get(sms.direction, "unknown"),
            "content": sms.text,
            "status": status,
            "backend": get_backend_name(sms.backend_id) or sms.backend_id,
            "phone_number": sms.phone_number
        }
        if error_message:
            message_data["error_message"] = error_message
        message_dicts.append(message_data)
    return message_dicts