Laravel Tutorials

Ship AI with Laravel: Give Your AI Agent Live Web Search

Published

▶️ Watch the video tutorial (8 minutes)

Our agent can look up orders, search the knowledge base, and hold real conversations. But ask it "is FedEx having delays right now?" and it has nothing useful to say. Our knowledge base covers our policies, not things that change by the minute. Shipping carrier delays, current product availability, outage pages. The agent either guesses or admits it doesn't know.

In this episode we fix that by giving the agent access to the live web. The SDK ships with two provider tools: WebSearch to find information online and WebFetch to read a specific page. The provider handles the actual searching, so we just configure which domains to allow and how many results to return.

I add WebSearch to the support agent, cap it at five results, and lock the allow list down to shipping carriers. That allow list is the part you don't skip. Without it the agent could browse anywhere on the internet and hand whatever it finds back to a customer. I also update the instructions so the agent stays transparent about where its answer came from, our official policy versus something it pulled off the web.

Then I test it. I ask about an order that shipped via FedEx with no tracking update, and the agent checks both the order and FedEx's status. I ask how long USPS Priority Mail takes, and it returns the current answer instead of guessing from training data that might be months old. I also show how to bias results by location if your customers are in a specific region.

One note: WebFetch is currently supported on Anthropic and Gemini. Since this series runs on OpenAI, we stick with WebSearch, which handles the use case fine.

That gives the agent five tools: order lookup, customer history, knowledge base search, document search, and now live web search. It can answer from our database, our documentation, and the live web.

Next episode we add the production infrastructure. Queued responses, provider failover, and middleware for logging and rate limiting. The stuff that keeps this running at 2am when you're asleep.

⭐ GitHub: https://github.com/harris21/ship-ai-with-laravel

▶️ Watch Episode 8 now →

Harris Raftopoulos photo

Senior Software Engineer • Staff & Educator @ Laravel News • Co-organizer @ Laravel Greece Meetup

Sponsored

laravelcloud logo
Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Visit Laravel Cloud

The latest

View all →
CPX: The Composer Package Executor for PHP image

CPX: The Composer Package Executor for PHP

Read article
Laravel AI SDK Adds Human-in-the-Loop Tool Approval image

Laravel AI SDK Adds Human-in-the-Loop Tool Approval

Read article
Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals image

Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals

Read article
Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs image

Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs

Read article
Blade Formatting in Laravel Pint image

Blade Formatting in Laravel Pint

Read article
Inertia DevTools Is Now on the Chrome Web Store image

Inertia DevTools Is Now on the Chrome Web Store

Read article