Skip to content

Console commands

All commands live under the chatbot: namespace.

CommandPurpose
chatbot:installPublish config, run migrations, write .env, inject Blade snippet. Idempotent.
chatbot:make-toolScaffold a new ChatbotTool class.
chatbot:inspect-promptDump the assembled prompt for a route as the LLM would receive it.
chatbot:pruneHard-delete conversations past the retention window.
chatbot:delete-userSoft- or hard-delete a user's conversations.
chatbot:export-userExport a user's conversations as JSON or CSV.
chatbot:anonymize-userScrub user identity while preserving token/cost aggregates.
chatbot:delete-guestDelete a guest token's conversations.

chatbot:install

bash
php artisan chatbot:install

Publishes config/chatbot.php, runs the package migrations, prompts for base_url / api_key / model and writes them to .env, then injects @chatbot into your primary layout immediately before </body>.

Safe to re-run. Skips steps already done.

chatbot:make-tool

bash
php artisan chatbot:make-tool GetWeather
php artisan chatbot:make-tool GetWeather --force

Writes a worked-example class to app/Chatbot/Tools/GetWeatherTool.php. Prints the exact Chatbot::registerTool(...) line to paste into a service provider.

Argument / flagDescription
nameBare class name (e.g. GetWeatherGetWeatherTool).
--forceOverwrite existing file. Without it, the command fails fast if the destination exists.

Publish stubs/chatbot-tool.stub via php artisan vendor:publish --tag=chatbot-stubs to customise the template.

chatbot:inspect-prompt

bash
php artisan chatbot:inspect-prompt \
  --route=orders.show \
  --channel=default \
  --user=42 \
  --context-json=sample-order-context.json

Dumps the full messages array as pretty-printed JSON, with a header showing the inspection parameters. Uses the same PromptAssembler and ContextSanitizer as live requests, so output is authoritative.

FlagRequiredDescription
--routeNamed route being simulated (used for labelling).
--channelChannel name. Defaults to default.
--userUser ID to include in the inspection header.
--context-jsonPath to a JSON file with sample context payload.

chatbot:prune

bash
php artisan chatbot:prune

Hard-deletes conversations whose last activity is older than chatbot.retention_days (per-channel overrides honoured). retention_days = null disables pruning for that channel.

Schedule it in routes/console.php:

php
Schedule::command('chatbot:prune')->daily();

chatbot:delete-user

bash
php artisan chatbot:delete-user 42
php artisan chatbot:delete-user 42 --hard
php artisan chatbot:delete-user 42 --channel=admin
Argument / flagDescription
idUser id (matched against chatbot_conversations.user_id).
--hardForce-delete instead of soft-delete.
--channelRestrict to a single channel.

chatbot:export-user

bash
php artisan chatbot:export-user 42 --format=json
php artisan chatbot:export-user 42 --format=csv > export.csv
Argument / flagDescription
idUser id.
--formatjson (default) or csv.

JSON output matches the chatbot-export@1 shape returned by HasChatbotData::exportChatbotData().

chatbot:anonymize-user

bash
php artisan chatbot:anonymize-user 42

Nullifies user_id on the user's conversations and scrubs personally-identifying content from message bodies, while preserving aggregate token / cost rows for billing or analytics continuity.

chatbot:delete-guest

bash
php artisan chatbot:delete-guest abc123token

Deletes conversations keyed to the given guest token.

Released under the MIT License.