Skip to content

A cloud-based, real-time football chatbot built with Dialogflow CX and Python webhooks, delivering smart sports insights through natural language.

License

Notifications You must be signed in to change notification settings

Arpangpta/Sportify-Football-Chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚽ Sportify: A Task-Oriented Football Chatbot (Dialogflow CX + GCP)

Sportify is a multi-intent, task-oriented sports chatbot built using Google Dialogflow CX, capable of providing real-time football information including scores, schedules, team stats, and more, primarily for the English Premier League (EPL). This project explores advanced conversational AI, with a strong focus on Natural Language Understanding (NLU) to accurately interpret user queries. It is deployed using webhooks + Google Cloud Functions, and thoroughly evaluated through both automated metrics and live user testing.


📌 Key Features

  • 🧠 Robust NLU Engine: Powered by Google Dialogflow CX to accurately understand user queries and extract critical information (slots) from natural language prompts. The system is trained on diverse samples to ensure high accuracy in understanding varied user prompts.

  • Real-Time EPL Data: Integrates with a RESTful API (specifically v3.football.api-sports.io) via Python webhooks to fetch up-to-the-minute data on:

    • Live game status (playingNow)

    • Latest match results and opponents (lastScore, lastOpponent, lastDateOfMatch)

    • Upcoming fixtures and opponents (nextGameDate, nextOpponent)

    • Comprehensive team statistics (leaguePosition, numGamesPlayed, winLossRecord)

    • Current manager details (manager)

  • ☁️ Scalable Cloud Deployment: Deployed using Google Cloud Functions for efficient, serverless execution of webhook logic, ensuring high availability and low latency.

  • 🎯 Multi-Intent & Slot Handling: Designed to process complex queries, identifying and extracting multiple pieces of information (slots) within a single user utterance.

  • 🗣️ Diverse Response Formats: Capable of delivering information in various formats to enhance user experience and engagement, including:

    • Text-based: Standard informative replies.

    • Visual/Card Mockups: Structured displays with images (e.g., player profiles, team logos, scrollable carousels for multiple items), enhancing visual appeal and information retention.

    • Audio Mockups: For non-visual interfaces, providing spoken responses.

    • Rich Responses: Combining multiple formats (e.g., cards with images and text, or video with audio and text) for comprehensive and immersive answers.

  • 👥 User-Centric Evaluation: Assessed with real users to validate NLU performance and conversational flow in practical scenarios, demonstrating an overall NLU accuracy of approximately 79%, and achieving up to 87% in specific user evaluations.


📁 Project Structure

Sportify-Football-Chatbot/
├── README.md
├── report/
│   ├── Report_merged.pdf         # Comprehensive project report including methodology, detailed NLU evaluation, and system design.
│   └── Extended Tables.pdf       # Supplementary document containing extended NLU evaluation tables from user testing.
├── webhook/
│   └── main.py                   # Python backend for Dialogflow CX webhook, handling API calls and response generation.
├── dialogflow_agent/
│   └── sportify-agent.blob       # (Conceptual) Exported Google Dialogflow CX agent for easy import.
└── LICENSE                       # (Conceptual) Project license file.

🔌 Technologies Used

  • Google Dialogflow CX: Core platform for building the conversational agent, managing intents, entities, flows, and the overall NLU model.

  • Google Cloud Functions: Serverless compute service used to host the webhook logic, providing scalability and integration with Dialogflow CX.

  • Python: Primary language for developing the webhook backend, facilitating data fetching and processing.

  • Flask: A lightweight Python web framework used within the webhook for handling incoming HTTP requests from Dialogflow CX.

  • REST APIs: External APIs (specifically v3.football.api-sports.io) are consumed to retrieve real-time sports data.


🧪 NLU Evaluation Highlights

The Natural Language Understanding (NLU) component was rigorously evaluated using extensive test sets and real user sessions. The primary focus was on the chatbot's ability to correctly identify user intents and extract relevant information (slots). The table below summarizes key performance metrics from the aggregated evaluation results.

Intent Precision Recall F1 Score
GetInfo 1.00 0.98 0.99
Other 0.94 1.00 0.97
Team 0.98 0.95 0.97
LastOpponent 0.71 0.71 0.71
LastScore 1.00 0.67 0.80
LeaguePosition 1.00 0.83 0.91
Manager 1.00 1.00 1.00
NextGameDate 1.00 0.33 0.50
NextOpponent 0.50 1.00 0.67
NumGamesPlayed 1.00 1.00 1.00
PlayingNow 0.50 1.00 0.67
WinLossRecord 0.22 0.67 0.33
Overall ~0.79 (Up to 0.87 in specific user evaluations)

Note: The WinLossRecord intent exhibited lower accuracy due to a higher degree of keyword overlap with other intents in the training data, highlighting a key area for future NLU model refinement and feature engineering.


💬 Sample Dialogues

Here are a few examples of interactions demonstrating Sportify's capabilities:

  • “Who is Manchester United playing next?”

  • “What’s the current score for Chelsea?”

  • “Give me Liverpool’s win-loss record.”

  • “Where is Tottenham in the league table?”

  • "Is Arsenal playing right now?"

  • "What place are Huddersfield in?"

  • "Hello, I need to know the record of Manchester City?"

Each query is meticulously processed through Dialogflow's NLU engine to determine the user's intent and extract relevant entities. This information then triggers the appropriate webhook call to fetch real-time data and formulate a dynamic, contextual response.


🚀 How to Use

To set up and run your Sportify chatbot:

  1. Dialogflow CX Agent Setup:

    • Navigate to your Google Dialogflow CX console.
    • Import the sportify-agent.blob file (conceptual, represents your exported agent) to deploy the pre-trained conversational flows, intents, and entities.
  2. Webhook Backend Deployment:

    • Deploy the Python code from webhook/main.py as a Google Cloud Function.
    • Ensure to configure your x-rapidapi-key for v3.football.api-sports.io securely, for instance, by setting it as an environment variable in your Cloud Function.
  3. Webhook Integration in Dialogflow CX:

    • In your Dialogflow CX agent, configure the deployed Google Cloud Function's URL as a webhook.
    • Associate this webhook with the fulfillment settings of your GetInfo intent and other relevant intents to enable dynamic data retrieval.
  4. Interaction:

    • You can interact with the chatbot using the built-in emulator within the Dialogflow CX console.
    • Alternatively, integrate the agent with a custom frontend application (e.g., web interface, mobile app) to provide a complete user experience.

🎓 Learning Outcomes & Future Scope

This project provided invaluable insights into the development and evaluation of advanced conversational AI systems:

  • Dialogflow CX Expertise: Gained comprehensive hands-on experience in building complex, stateful conversational agents, including advanced flow design, granular intent and entity creation, and systematic NLU model tuning.

  • Webhook Integration & API Orchestration: Mastered the crucial skill of connecting conversational AI with external real-time data sources through robust webhook implementations and efficient API management within cloud environments.

  • Conversational Design & Evaluation: Applied best practices in conversational design and performed rigorous user evaluations to assess NLU performance, identify critical areas for improvement, and validate real-world usability and user satisfaction.

  • Scalable Architecture: Developed a foundational understanding of deploying serverless functions for efficient and scalable conversational AI backends.

Future Enhancements: Sportify is designed with extensibility in mind. Potential future developments include:

  • Broader Sports Coverage: Expanding capabilities to cover other major sports leagues and events (e.g., NBA, Rugby, Formula 1, Baseball, Hockey).

  • Dynamic Persona Customization: Implementing features that allow users to define or select custom chatbot personas (e.g., sports commentator voice/tone) for a more personalized interaction.

  • Advanced Multi-modal Responses: Integrating richer response types, such as short video highlights, animated graphs, and more interactive card mockups.

  • Multi-language Support: Adding support for more languages to reach a global audience.


📄 License

This project is submitted as part of a Master's level AI course at the University of Glasgow. Usage is permitted for educational and research purposes with proper attribution.


👤 Author

Arpan Gupta 🎓 MSc AI & Robotics, University of Glasgow

🔗 GitHub | Kaggle

About

A cloud-based, real-time football chatbot built with Dialogflow CX and Python webhooks, delivering smart sports insights through natural language.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages