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 →
Lerd: A Free, Open Source Herd Alternative for Linux and macOS image

Lerd: A Free, Open Source Herd Alternative for Linux and macOS

Read article
Let's Encrypt HTTPS on an IP Address With FrankenPHP image

Let's Encrypt HTTPS on an IP Address With FrankenPHP

Read article
Laravel Chores: Resumable Data Operations and Cleanups image

Laravel Chores: Resumable Data Operations and Cleanups

Read article
NativePHP v4: Build Native iOS and Android UI in Blade image

NativePHP v4: Build Native iOS and Android UI in Blade

Read article
Laravel Lock: Distributed Locks for Models and Routes image

Laravel Lock: Distributed Locks for Models and Routes

Read article
Laravel Image Responses: Serve Resized Images From Routes image

Laravel Image Responses: Serve Resized Images From Routes

Read article