Skip to content

HTTP endpoints

All routes are registered under routes/chatbot*.php and prefixed with /chatbot. Routes marked public contract are governed by the semver policy.

MethodPathNameControllerNotes
POST/chatbot/messageschatbot.messagesMessagesControllerpublic contract; under route_middleware
GET/chatbot/conversations/{id}/messageschatbot.conversations.messagesHistoryControllerpublic contract; under route_middleware
GET/chatbot/healthchatbot.healthHealthControllerpublic contract; no middleware
GET/chatbot/widget.jschatbot.widget-js(inline closure)public contract; no middleware
GET/chatbot/test-fixturechatbot.playwright-fixturePlaywrightFixtureControllerinternal — active only when playwright_fixture.enabled = true; for the package's own e2e suite

The POST /chatbot/messages and GET /chatbot/conversations/{id}/messages routes, plus the conditional /chatbot/test-fixture render route, are wrapped in the route_middleware group (default: ['web']). GET /chatbot/health and GET /chatbot/widget.js are always outside that group.

POST /chatbot/messages

Send a user message and stream the assistant reply.

Request body

FieldTypeRequiredDescription
signed_contextstringThe signed envelope minted by @chatbot at page render.
messagestringThe user's message.
conversation_idintContinue an existing conversation. Omit to start a new one.
client_extractorsobjectMap of name → string blocks produced by client extractors. Each name must be in the envelope's allowlist.

Response

Content-Type: text/event-stream. See SSE events for the event shape.

Errors

StatusCause
403InvalidEnvelopeException family — tampered, expired, route/channel mismatched.
422Validation failure (missing field, disallowed extractor name).
429Throttle exceeded (chatbot.throttle.per_minute or per_day).
500Internal error. Detail in logs.

Provider/quota/timeout errors arrive on the open stream as error SSE events, not HTTP status codes.

GET /chatbot/conversations/{id}/messages

Fetch the persisted message history for a conversation. {id} is the conversation's public UUID (string).

Query parameters

ParameterRequiredDescription
signed_contextThe signed envelope minted by @chatbot at page render. The envelope's identity is used to verify ownership.

Response

json
{
  "messages": [
    { "role": "user",      "content": "Where is my order?", "route_name": "orders.show", "context_hash": "abc123", "created_at": "2024-01-01T00:00:00+00:00" },
    { "role": "assistant", "content": "It ships tomorrow.", "route_name": "orders.show", "context_hash": "abc123", "created_at": "2024-01-01T00:00:01+00:00" }
  ]
}

If the channel has a greeting configured it is prepended as the first message (role: assistant) and is not stored in the database.

Errors

StatusCause
403Missing or invalid signed_context, or the conversation belongs to a different identity.
404No conversation with that UUID.

Access control uses the verified envelope identity — the conversation must be owned by that user (or matching guest token).

GET /chatbot/health

Lightweight health probe.

Response

json
{
  "version": "1.0.0",
  "active_streams": 3,
  "status": "ok"
}

Use for liveness checks. Returns 200 with status: ok when the package is bootable and migrations are present; otherwise 503.

GET /chatbot/widget.js

Serves the bundled web component (dist/chatbot-widget.js) as application/javascript. The @chatbot Blade directive emits a <script type="module" src="/chatbot/widget.js"> referencing this route.

Released under the MIT License.