Introducing FoodMood-Bot: Your WhatsApp Chef Tailoring Recipes to Your Mood - Twilio Challenge Submission 2024
Tags: devchallenge, twiliochallenge, ai, twilio
Published: 2024-06-24 06:14:07

*This is a submission for [Twilio Challenge v24.06.12](https://dev.to/challenges/twilio)*


## What I Built
<!-- Share an overview of your project. -->

![FoodMood-Whatsapp-Bot_post](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cmtl13leul5zzr9z4xvj.png)
. 
FoodMood-Bot is designed to enhance the cooking experience by providing mood-based recipe recommendations and personalized food-related assistance. It leverages the capabilities of Twilio and OpenAI to create an interactive and engaging user experience on WhatsApp.


## Twilio and AI
<!-- Tell us how you leveraged Twilio’s capabilities with AI -->
I used [Twilio's WhatsApp API](https://www.twilio.com/docs/whatsapp/tutorial) to interact with users in real-time, collecting mood inputs and delivering tailored recipe suggestions and Openai's [Chat completion] (https://platform.openai.com/docs/api-reference/chat/create) and [Create Image](https://platform.openai.com/docs/api-reference/images) APIs. OpenAI powers the bot's ability to understand and respond to user queries intelligently, ensuring that the food recommendations are both appropriate and enjoyable. 


![Twilio WhatApp API Sandbox](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ygxrrv5qtwpddczyhokj.png)



## Demo
<!-- Share a link to your app and include some screenshots here. -->
Check out the live demo: [FoodMood-Bot Demo](https://your-demo-link.com)

[Check the GitHub Repository](https://github.com/harshitadharamansharma/FoodMood-Bot-Whatsapp)

[Backend](https://foodmood-bot-whatsapp.onrender.com)

Chat with the bot on this number:- +14155238886


[demo-1](https://photos.app.goo.gl/GoUpQigBAUu47hQr9)
[demo-2](https://photos.app.goo.gl/FfLGgJ22Gj1b1w1Q7)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m5xhx8ndd546u5rzfc1u.jpg)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5rehamnowq0t4j4vczpk.jpg)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tgk390mekh23epzo9n2x.jpg)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f571sw040ryw0baobggc.jpg)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fde029fcq1qtcnx65csp.jpg)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uzflgqmnfupn5htg9o4y.jpg)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t851hu50ch3fde58dcfl.jpg)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z51jevq41tsi47qqkyyi.jpg)


### 🍽️ FoodMood-Bot

**FoodMood-Bot** is a WhatsApp bot powered by Flask, Twilio, and OpenAI, developed by HarshitaDS in June 2024. It suggests recipes based on the user's mood, providing brief, easy-to-follow instructions with ingredients and preparation time.

### Features

- 🌟 **Mood-Based Food Suggestions**: Get recipe recommendations based on your current mood.
- 📋 **Brief Recipes**: Each recipe is concise (not more than 1400 characters) and includes ingredients and preparation time.
- 👫 **Portion Size**: Ingredients list is prepared for 2 people.
- 🍽️ **Personalized Assistance**: Responds to thank you messages with amazing food-related quotes and offers further assistance.
- 🖼️ **Image Generation**: Generate images related to your query by starting your message with `/img`.

### How It Works

1. **Mood Detection**: The bot asks for your current mood and suggests a suitable recipe.
2. **Recipe Delivery**: Provides a brief recipe with a list of ingredients and the preparation time.
3. **Portion Control**: All recipes are tailored for 2 people.
4. **Image Generation**: Start your message with `/img` to receive a generated image related to your query.

### Example Interaction

User: I'm feeling happy today!
FoodMood-Bot: That's wonderful! How about celebrating with a refreshing fruit salad? 🍓🍊 Here's a quick recipe:

Ingredients:

- 1 cup strawberries, sliced
- 1 orange, peeled and segmented
- 1 apple, diced
- 1 tablespoon honey
- 1 tablespoon lemon juice

**Preparation Time:** 10 minutes

1. In a large bowl, combine the strawberries, orange segments, and apple.
2. Drizzle with honey and lemon juice.
3. Toss gently to mix. Enjoy your refreshing fruit salad!

User: Thank you!
FoodMood-Bot: "One cannot think well, love well, sleep well, if one has not dined well." - Virginia Woolf. I'm here for any further assistance you may need!


### Technologies Used

- **Flask**: For creating the web application.
- **Twilio**: For WhatsApp messaging API.
- **OpenAI**: For intelligent responses and mood analysis.

### Installation

1. Clone this repository:
    ```bash
    git clone https://github.com/HarshitaDS/FoodMood-Bot.git
    cd FoodMood-Bot
    ```
2. Create a virtual environment and activate it:
    ```bash
    python -m venv venv
    source venv/bin/activate  # On Windows use `venv\Scripts\activate`
    ```
3. Install dependencies:
    ```bash
    pip install -r requirements.txt
    ```
4. Set up your environment variables:
    - `TWILIO_ACCOUNT_SID`
    - `TWILIO_AUTH_TOKEN`
    - `OPENAI_API_KEY`

5. Run the Flask application:
    ```bash
    flask run
    ```

### Usage

- Initiate a conversation with the bot on WhatsApp.
- Provide your current mood when prompted.
- Receive a personalized recipe suggestion.
- Start your message with `/img` to generate an image related to your query.
- Enjoy your meal!

### Contributing

Contributions are welcome! Please fork this repository and submit a pull request.

### License

This project is licensed under the MIT License.

### Contact

Developed by HarshitaDS. For any inquiries, please reach out via GitHub.


## Additional Prize Categories

**Impactful Innovators:** This will help in getting customized food options as per the mood, so nothing will get wasted. 😎
**Entertaining Endeavors:** Gives interesting food-related quotes and images when asked that will increase the appetite. 😋 



<!-- Team Submissions: Please pick one member to publish the submission and credit teammates by listing their DEV usernames directly in the body of the post. -->



<!-- Don't forget to add a cover image (if you want). -->

<!-- Thanks for participating! -->