Text Messaging – Routes & Access Control

This section details how text messaging routes are registered in the Prep Network Events platform, and how access is controlled for creating, cloning, and retrieving event-related data for texting campaigns. It also covers the publicly exposed Twilio Notify webhook route.

Route Registration

All text messaging routes live in routes/texting.php. They are loaded via the mapTextingRoutes() method in App\Providers\RouteServiceProvider, which applies the web middleware (session state, CSRF protection, etc.) to the group before including this file.

Public Webhook Endpoint 📡

Twilio Notify delivery callbacks must reach your application without authentication. The following public route handles these callbacks:

// routes/texting.php
Route::post(
    '/twilio-texting-campaign-notify-webhook',
    [TwilioWebhookController::class, 'handleNotifyWebhook']
);
  • Purpose: Receives delivery status updates from Twilio Notify (e.g., “SENT”, “FAILED”).
  • Handler: App\Http\Controllers\TwilioWebhookController::handleNotifyWebhook.
  • Access: No authentication or role checks—Twilio must call this endpoint directly.
{
    "title": "Twilio Notify Delivery Callback",
    "description": "Handles Twilio Notify status callbacks for texting campaigns",
    "method": "POST",
    "baseUrl": "https://events.prephoops.com",
    "endpoint": "/twilio-texting-campaign-notify-webhook",
    "headers": [],
    "queryParams": [],
    "pathParams": [],
    "bodyType": "form",
    "requestBody": "AccountSid=ACxxx&ServiceSid=ISxxx&NotificationSid=NTxxx&DeliveryState[]=JSON_STRING",
    "formData": [],
    "rawBody": "",
    "responses": {
        "200": {
            "description": "Callback processed"
        },
        "404": {
            "description": "Invalid AccountSid or ServiceSid"
        }
    }
}

Note: Always verify AccountSid and ServiceSid in the payload to ensure authenticity.

Protected Text Messaging Routes 🔒

All campaign management routes require a logged-in user with one of these roles:

  • Admin
  • Event Manager
  • Event Director

They are nested under the auth middleware and a role check, as shown below:

// routes/texting.php
Route::middleware('auth')->group(function () {
    Route::middleware('role:Admin|Event Manager|Event Director')->group(function () {
        Route::resources([
            'texting-campaigns' => TextingCampaignController::class,
        ]);

        // Retrieve event data for campaign UI
        Route::get(
            '/texting/getEventData/{event}',
            [TextingCampaignController::class, 'getEventData']
        )->name('texting-campaigns.getEventData');

        // Duplicate an existing campaign
        Route::get(
            '/texting/{textingCampaign}/clone',
            [TextingCampaignController::class, 'clone']
        )->name('texting-campaigns.clone');
    });
});

Middleware Stack

  • auth: Ensures the user is authenticated.
  • role:Admin|Event Manager|Event Director: Restricts access to the specified roles (powered by Spatie’s Role middleware).

Campaign Endpoints

Method URI Action Route Name
GET /texting-campaigns TextingCampaignController@index texting-campaigns.index
GET /texting-campaigns/create TextingCampaignController@create texting-campaigns.create
POST /texting-campaigns TextingCampaignController@store texting-campaigns.store
GET /texting-campaigns/{id} TextingCampaignController@show texting-campaigns.show
GET /texting-campaigns/{id}/edit TextingCampaignController@edit texting-campaigns.edit
PUT/PATCH /texting-campaigns/{id} TextingCampaignController@update texting-campaigns.update
DELETE /texting-campaigns/{id} TextingCampaignController@destroy texting-campaigns.destroy
GET /texting/getEventData/{event} TextingCampaignController@getEventData texting-campaigns.getEventData
GET /texting/{textingCampaign}/clone TextingCampaignController@clone texting-campaigns.clone

Roles & Responsibilities

  • Admin: Full CRUD access to campaigns.
  • Event Manager: Same as Admin for campaign management.
  • Event Director: Can list, view, and create campaigns for events they manage (filtered in controller).
{
    "title": "Access Control",
    "content": "Only Admin, Event Manager, or Event Director roles can manage texting campaigns."
}

By centralizing route definitions in routes/texting.php and leveraging Laravel’s middleware groups, the platform ensures secure, role-based access to text messaging features, while keeping the webhook endpoint publicly accessible for Twilio integrations.