Skip to content
Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

86 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🍝 Recipe Chatbot - OpenAi_project

A responsive web application built with Next.js, developed in TypeScript and styled with TailwindCSS, integrating the OpenAI API to deliver a culinary-themed chatbot.

Upon entering the web application, the user interacts with a virtual waiter to request a specific recipe.

Then, the AI Waiter Agent proposes 3 randomly selected chefs from the available list.

Once the user selects a chef, a chat starts with that chef, after an intentionally long and frustrating wait time.

Each private chat with a chef is limited to 5 interactions (questions and answers).

However, the chefs always give confusing and humorous answers, aiming to prolong the conversation without ever actually providing the requested recipe.

After the chat ends, the AI Waiter Agent suggests another chef from the available list for the user to talk to, repeating the same cycle.

🎯 Project Goal

This web application is designed to balance frustration with usability, creating a funny paradox that keeps users engaged.

Agents’ prompts are designed to produce funny, unpredictable, and confusing responses.

All steps update the session (history and step) to maintain flow consistency.

This project is not meant to be a serious cooking assistant. Instead, it is a creative experiment in human–AI interaction that aims to:

  • Playfully engage users in a culinary context
  • Explore unconventional UX with humor and irritation
  • Showcase the integration of Next.js, TailwindCSS, and OpenAI API in a real-world application

πŸš€ Features

  • No authentication required – instant access to the platform
  • Virtual waiter persona with humorous and sarcastic tone
  • Select Chefs (Modal) – multiple personalities with integrated agents
  • Dynamic conversation powered by OpenAI
  • Responsive UI styled with TailwindCSS

πŸ› οΈ Tech Stack


πŸ“¦ Setup Instructions

1. Clone the repository

git clone https://github.com/StefAltavista/OpenAi_project.git
cd OpenAi_project

2. Install dependencies

Make sure you have Node.js (>=18) installed, then run:

npm install

3. Configure environment variables

Create a .env.local file in the project root and add your OpenAI API key:

OPENAI_API_KEY=your_api_key_here

4. Start the development server

npm run dev

The app will be available at http://localhost:3000.

5. Build for production

npm run build
npm start

πŸ“‚ Project Structure

The repository is organized as follows:

OpenAi_project/
β”œβ”€β”€ .next/                 # Build output (auto-generated by Next.js)
β”œβ”€β”€ node_modules/          # Installed dependencies
β”œβ”€β”€ public/                # Static assets (images, icons, etc.)
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/               # Next.js routing and pages
β”‚   β”œβ”€β”€ components/        # Reusable UI components
β”‚   β”œβ”€β”€ data/              # Static data or mock data
β”‚   β”œβ”€β”€ hooks/             # Custom React hooks
β”‚   └── lib/               # Utility functions and helpers
β”œβ”€β”€ config/                # Project configurations (Next.js, Tailwind, ESLint, etc.)
└── README.md              # Project documentation

Interaction with OpenAI

This documentation describes how the application interacts with OpenAI through three agents:

  • Waiter Agent β†’ general conversational assistant, ironic and deliberately unhelpful.
  • Cook Agent β†’ guides recipe preparation with confusing responses and deliberately wrong ingredients.
  • AI Assistant (JSON Creator) β†’ technical agent that returns only structured JSON outputs, used to extract information from Cook's responses.

πŸ”„ General Flow Diagram

[User] -> [Frontend React] -> Waiter Agent / Cook Agent -> AI Assistant -> Updated session


🍽️ Waiter Agent – POST /api/waiter

Overview

Manages general user conversation in a ironic and deliberately unhelpful tone, updating the session state step-by-step via switchWaiterState.

Main Steps and Prompts

Step Prompt / Instructions Expected Behavior
WELCOME "You are a digital Waiter in an app that provides recipes upon request. Greet and welcome the user..." Short greeting (<20 words), ironic tone
ASK_RECIPE "Answer politely to whatever the user says. Ask what recipe they want." Invite user to choose a recipe, playful tone
PROPOSE_COOK "Extrapolate the name of the recipe from this message..." Identify recipe, propose random cooks
COOK_SELECTED "Give a weird feedback about the user's choice..." Ironic/absurd comment, handoff to Cook
RETURN_TO_WAITER "Apologize to the user and offer new cooks..." Ironic tone, new selection of cooks

Example Conversation

User: "I want advice for dinner."
Waiter: "Dinner? Wasn't it breakfast time? I'd eat cookies and see how it goes."


πŸ‘¨β€πŸ³ Cook Agent – POST /api/cook

Overview

Guides the user through the recipe in a deliberately confusing and ironic way, also producing ingredient lists that are often wrong.
For creation of this agent we followed the guidelines of OpenAi documentation: Agents SDK TypeScript -> https://openai.github.io/openai-agents-js/

Main Steps and Prompts

Step Prompt / Instructions Expected Behavior
SALUTE "Say Hello, make a silly comment about the recipe, ask if user has a diet" Ironic greeting and joke about the recipe
ASK_ALLERGY "Extrapolate diet info from the user message" Store any diet information
RANDOM_QUESTION "Extrapolate allergies and ask a random question" Absurd question, playful tone
LIST_INGREDIENTS "Now give a wrong recipe with random scales, maybe wrong allergens" Deliberately wrong ingredients, confusing
END "Say goodbye and handoff to the waiter" Ends session with ironic tone
RETURN_TO_WAITER "The cook session has ended. Returning to the waiter..." Session ended, handoff to Waiter

Code extract

/lib/switchCookState.ts

import { run } from "@openai/agents"; // call function run from openai libraries
import { ai_assistant } from "./ai_assistant";

type CookState =
  | "SALUTE"
  | "ASK_ALLERGY"
  | "ASK_DIET"
  | "RANDOM_QUESTION"
  | "LIST_INGREDIENTS"
  | "END"
  | "RETURN_TO_WAITER";

export interface CookSession {
  id: string;
  cookID: string;
  recipe: string;
  step: CookState;
  history: { role: string; content: string }[];
  allergies?: string[];
  diet?: string[];
  ingredients?: string[];
}

// Function to switch the state of the cook session based on the current step

export default async function switchCookState(
  session: CookSession
): Promise<CookSession> {
  const bot = ai_assistant();
  let response;

switch (session.step) {
    // Initial greeting and asking about diet
    case "SALUTE":
      session.history.push({
        role: "cook",
        content: `Say Hello to our guest, make a silly comment about the recipe and ask if the user is on a specific diet`,
      });
      session.step = "ASK_ALLERGY";
      return session;

...

Example Conversation

User: "How do I make carbonara?"
Cook: "First throw chocolate into the spaghetti… oh and add a pinch of sugared pepper!"


πŸ€– AI Assistant – lib/ai_assistant.ts

Overview

Technical agent that returns only JSON.
Mainly used by the Cook Agent to extract structured data (ingredients, messages).

Example Output

Input:

Extrapolate ingredients in JSON from: "Great! For a carbonara you need spaghetti, guanciale, eggs, and pecorino."

Output:

{
  "message": "Great! For a carbonara you need...",
  "ingredients": ["spaghetti", "guanciale", "eggs", "pecorino"]
}

☁️ Deployment on Vercel

This project can be easily deployed to Vercel, the official platform for Next.js apps.

1. Push to GitHub

Ensure your repository is available on GitHub.

2. Import the project into Vercel

  • Go to Vercel Dashboard
  • Click New Project β†’ Import Git Repository
  • Select your GitHub repository

3. Configure environment variables

In the Vercel dashboard, go to Settings β†’ Environment Variables and add:

OPENAI_API_KEY=your_api_key_here

4. Deploy

Click Deploy and wait for the process to complete.

Once deployed, your app will be available at:

https://your-project-name.vercel.app

About

Team project on the implementation of an AI ChatBot - Chatbot di attesa telefonica infinita

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages