DEV Community

Cover image for Namaste Your Way to Wellness: AI-Powered Yoga Recommendations
Aadarsh Kannan
Aadarsh Kannan

Posted on

Namaste Your Way to Wellness: AI-Powered Yoga Recommendations

This is a submission for the Twilio Challenge

Today is International Yoga Day! Whether you're a seasoned yogi or just dipping your toes into the world of yoga, it's the perfect day to embrace the benefits of this ancient practice. And there's no better way to celebrate than with YogaConnect, your new personalized yoga companion.

What I Built

YogaConnect is designed to make your yoga journey enjoyable and tailored to your needs. With personalized routines, and helpful wellness tips, YogaConnect ensures you stay motivated and on track. Here’s how YogaConnect can help you make the most out of your yoga practice:

Key Features of YogaConnect

Personalized Yoga Recommendations
YogaConnect uses AI to analyze your experience level, goals, and any physical limitations to provide personalized yoga poses. Whether you're a beginner, intermediate, or advanced practitioner, YogaConnect tailors routines that fit your unique needs.

Interactive User Interface
Built on Streamlit, YogaConnect offers a clean and interactive interface. Easily input your details, view recommendations, and access video tutorials seamlessly, making your yoga journey smooth and enjoyable.

Email Follow-Ups
To keep you motivated, YogaConnect sends detailed follow-up emails containing your personalized yoga routines and additional wellness tips. Leveraging Twilio's SendGrid, these emails are delivered consistently and reliably to keep you engaged and informed.

How YogaConnect Works

Step 1: Tell Us About Yourself

Upon visiting YogaConnect, you’ll be prompted to fill in your details:
Yoga Experience Level: Choose from Beginner, Intermediate, or Advanced.
Yoga Goals: Select your goals such as Flexibility, Strength, or Relaxation.
Physical Limitations: Optionally, you can specify any physical limitations you might have.
Email Address: Provide your email address to receive follow-up emails.

Step 2: Get AI-Powered Recommendations

Once you submit your details, YogaConnect uses Gemini AI engine to generate a list of recommended yoga poses tailored to your profile. This ensures that the yoga routine fits your specific needs and goals.

Step 3: Watch Video Tutorials

For each recommended pose, YogaConnect fetches a relevant instructional video from YouTube, ensuring you have a clear visual guide to follow. This makes it easier to practice each pose correctly and safely.

Step 4: Receive Email Delivery

After generating your personalized yoga routine, YogaConnect sends an email to the provided address with all the details. This email includes:

The name and Sanskrit name of each pose.
The benefits of each pose.
The best time to perform each pose.
Suggestions and tips for each pose.
Links to video tutorials.

Demo

Check out the YogaConnect app!

YogaConnect Home

YogaConnect Recommendation

YogaConnect Email

Twilio and AI

Twilio's SendGrid and Dynamic Templates

Twilio's SendGrid is a cloud-based service that provides a reliable and scalable platform for sending transactional and marketing emails. It is widely used for sending notifications, newsletters, and other automated email communications. SendGrid offers robust features such as analytics, template management, and email deliverability tools.

Dynamic templates in SendGrid allow you to create email templates with placeholders that can be filled with dynamic data when the email is sent. This feature is particularly useful for sending personalized emails where the content can change based on the recipient's data.

Here’s how dynamic templates are typically used:

  • Create a Dynamic Template: In the SendGrid dashboard, create a new email template and define placeholders for the dynamic content.

  • Define Template Variables: Use placeholders in the template body, such as {{name}} or {{yoga_pose}}, which will be replaced with actual data when the email is sent.

Sendgrid Dynamic Template

  • Send Email with Dynamic Data: When sending the email via the SendGrid API, pass the dynamic data in the request to populate the placeholders.

Example of Sending Dynamic Emails

In YogaConnect, we use a dynamic template to send personalized yoga routines. Here’s the code that handles this:

def send_dynamic_email(to_emails, email_content):
    FROM_EMAIL = 'FROM_EMAIL'
    TEMPLATE_ID = 'SENDGRID_TEMPLATE_ID'

    message = Mail(
        from_email=FROM_EMAIL,
        to_emails=[to_emails]
    )
    message.dynamic_template_data = {
        'content': email_content
    }
    message.template_id = TEMPLATE_ID

    try:
        sg = SendGridAPIClient(SENDGRID_API_KEY)
        response = sg.send(message)
        print("Dynamic Messages Sent!")
        return "Dynamic Messages Sent!"

    except Exception as e:
        print(f"Error: {e}")
    return "Error sending email"
Enter fullscreen mode Exit fullscreen mode

TEMPLATE_ID: The ID of the dynamic template created in the SendGrid dashboard.

dynamic_template_data: A dictionary containing the data to replace placeholders in the template.

SendGridAPIClient: Used to send the email via the SendGrid API.

Google Gemini AI

In YogaConnect, Google Gemini AI is used to generate personalized yoga recommendations based on user input. The model is configured to ensure relevant and accurate responses tailored to each user's needs.

Using Google AI Studio, I created a Structured Prompt that returns the required parameters in JSON format.

Google AI Studio

Here's how I configure and use Google Gemini AI in YogaConnect:

import google.generativeai as genai

genai.configure(api_key=GEMINI_API_KEY)

generation_config = {
  "temperature": 1,
  "top_p": 0.95,
  "top_k": 64,
  "max_output_tokens": 8192,
  "response_mime_type": "application/json",
}

model = genai.GenerativeModel(
  model_name="gemini-1.5-flash",
  generation_config=generation_config,
)
Enter fullscreen mode Exit fullscreen mode

GEMINI_API_KEY: API key for accessing Google Gemini AI services.

generation_config: Configuration settings for the model to control the output's creativity and coherence.

The get_ai_recommended_poses function uses the configured Gemini model to generate yoga pose recommendations based on user input.

Additional Prize Categories

YogaConnect fits the "Impactful Innovators" category by promoting physical and mental well-being through personalized yoga recommendations. By leveraging AI, the app offers tailored yoga practices that cater to individual needs, helping users achieve specific wellness goals such as flexibility, strength, and stress reduction

Links/References


I will keep on updating the project before the deadline.
Banner credit: People illustrations by Storyset
Thanks for the read and I appreciate your feedbacks!

Top comments (0)