Build an AI Chat Agent with GPT-4o for Weather & News Queries

Create an intelligent chat agent using GPT-4o that interprets user intent and automatically routes to the right tool, fetching real-time weather from OpenWeatherMap or news headlines from NewsAPI.

1.9K
uses
4.7
rating
8 min setup
Setup
Webhook AI chatbot OpenAI GPT-4o agent OpenWeatherMap integration NewsAPI automation
Live Preview
Use this template

About This Template

Build a production-ready AI chat agent that understands natural language and automatically selects the right tools to answer questions. This puq.ai template uses GPT-4o to interpret user intent, route requests to appropriate APIs, and format responses — all accessible via a simple webhook endpoint.

Designed for developers building intelligent chatbots and conversational interfaces, this workflow demonstrates the agentic pattern of AI tool selection while providing real utility through weather and news integrations.


How This Automation Works

1. Receive Chat Messages via Webhook

The workflow exposes a POST endpoint at /chat that accepts user messages in JSON format, ready to integrate with any chat interface.

2. AI Intent Detection with GPT-4o

GPT-4o analyzes the user message and determines which tool to use:

  • Weather Tool — When users ask about weather, temperature, or conditions
  • News Tool — When users request news, headlines, or current events
  • Direct Answer — When no external data is needed

3. Intelligent Parameter Extraction

The AI extracts relevant parameters from natural language:

  • Location names for weather queries ("What's the weather in Tokyo?")
  • Topics for news queries ("Show me news about AI")

4. Weather Tool Path

Weather requests are processed through:

  • OpenWeatherMap API — Fetches real-time weather data
  • GPT-4o-mini Formatting — Converts API data to friendly response with practical advice (umbrella, sunscreen, etc.)

5. News Tool Path

News requests are processed through:

  • NewsAPI — Retrieves latest articles by topic
  • GPT-4o-mini Summarization — Creates concise headline summaries

6. Structured Webhook Response

All paths return structured JSON responses via webhook, making integration with chat UIs, Slack bots, or custom applications seamless.


Key Benefits

  • Agentic AI with automatic tool selection
  • Natural language understanding via GPT-4o
  • Real-time weather data integration
  • Current news retrieval and summarization
  • Webhook-based API for easy integration
  • Structured JSON responses
  • Fallback to direct AI answers
  • Production-ready error handling

Use Cases

  • Building custom AI chatbots
  • Adding AI capabilities to existing applications
  • Creating Slack or Discord bots with real-time data
  • Prototyping conversational AI interfaces
  • Learning agentic AI patterns
  • Building voice assistant backends

Integrations Used

  • Webhook — HTTP endpoint for chat messages and responses
  • OpenAI GPT-4o — Intent detection and tool selection
  • OpenAI GPT-4o-mini — Response formatting and summarization
  • OpenWeatherMap — Real-time weather data API
  • NewsAPI — Current news articles by topic

Why Use This puq.ai Template?

Building AI agents from scratch requires complex orchestration logic. This template provides a working agentic pattern you can extend — demonstrating tool selection, parameter extraction, API integration, and response formatting in a production-ready package.

With puq.ai, you deploy an intelligent chat agent in minutes — no backend code, no orchestration complexity, no API plumbing.


Get Started in Minutes

  • Import the template into puq.ai
  • Connect your OpenAI account
  • Add your OpenWeatherMap API key
  • Add your NewsAPI key
  • Get your webhook URL and start sending messages
  • Integrate with your chat interface or application

Ask anything. Route intelligently. Respond naturally.

Use this template to build AI-powered chat agents that understand intent and fetch real-time data — powered by GPT-4o intelligence and orchestrated by puq.ai.

How This Automation Works

1

Trigger Event

The workflow starts when a specific event occurs in your connected app.

2

Process Data

puq.ai processes the incoming data and applies any filters or transformations.

3

Execute Action

The processed data triggers actions in your destination apps automatically.

Ready to Automate Your Workflows?

Join thousands of businesses that trust puq.ai to streamline their operations and boost productivity.

Get Started