Inspiration

Growing up, whispered conversations and half-truths were all we had when it came to sexual and reproductive health. No one talked about these things openly where I'm from – they were wrapped in layers of stigma and awkward silences. I watched my girlfriends missing school during their periods and I spent hours upon hours on the internet trying to find relevant information as a confused teen.

Years later, as a PhD student at Harvard working on African development to improve girls' education and health outcomes, I saw the same patterns playing out. According to a 2024 UNICEF and WHO report and other development studies, the lack of accurate information about sexual and reproductive health has severe consequences—from widespread menstrual stigma causing school absences in Ethiopia to disproportionate HIV rates in Cameroon, where young women's infection rates are five times higher than their male counterparts.

But this time my perspective had shifted from that confused young student to someone who could actually create change. When my friend Dora, a computer scientist, reached out to me about this Hackathon, we were excited to see it as an opportunity to build an AI product that we both believed in and could have a real impact on girls' health and education outcomes in Africa and around the world.

What it does

Our AI product is called WhispHer, a Gemini-powered chatbot accessible through WhatsApp. It provides a confidential, judgment-free space for young women to ask questions and receive accurate, scientifically backed answers about sexual health, menstrual care, and overall well-being. Users can simply text a number on WhatsApp to connect with WhispHer. By offering reliable information anonymously, WhispHer is designed to break through cultural taboos that have long kept girls in the dark.

Our choice of WhatsApp as the primary platform leverages its unprecedented market penetration in Sub-Saharan Africa, where it reaches 97% of internet users in Kenya and represents 44% of Zimbabwe's mobile internet traffic. This established user base ensures minimal adoption barriers in our target markets. Beyond its extensive market penetration, WhatsApp offers crucial technical advantages: it performs reliably in low-bandwidth areas, consumes minimal data making it more cost-effective than alternatives such as Google search, and requires no additional app downloads.

How we built it

Step 1: Configure Gemini-1.5 Model to Act as an OB-GYN Assistant

WhispHer chatbot utilizes the Gemini-1.5-flash-002 model through Google’s VertexAI as a friendly OB-GYN assistant that provides guidance and support on women’s reproductive and sexual health. Here’s a quick overview of the setup:

  1. Model Selection: The Gemini-1.5-flash-002 model was chosen for its high-quality, contextual responses, eliminating the need for fine-tuning.

  2. Prompt Configuration: We used specific prompts to guide the model’s responses. The key goals were to:

    • Offer scientifically accurate and culturally sensitive responses.
    • Avoid specific medical diagnoses and advice.
    • Provide a safe, non-judgmental space for user queries.
    • Reflect a deep understanding of women’s health in the context of conservative societies.
  3. Custom Instructions: The prompt includes instructions for the model to use simple language, avoid jargon, and empower users with general information and links to resources.

Step 2: Integrate the Gemini Model with WhatsApp Using Twilio and NGROK

To connect the WhispHer chatbot to WhatsApp, we leveraged Twilio for messaging and NGROK to expose our local server to the internet, enabling external access. Here’s how:

  1. Set Up NGROK: NGROK was used to create a public endpoint for our local server, making it accessible to WhatsApp and Twilio. This allowed our development environment to communicate with Twilio's API.

  2. Twilio Configuration: Twilio provides a sandbox for testing WhatsApp interactions. We created a config file (.env) to store:

    • Twilio Account SID and Auth Token.
    • WhatsApp number for messaging.
    • Google Cloud project and authentication details for Vertex AI.
  3. Bot Script:

    • bot.php listens for incoming messages and directs them to our Python script (response.py).
    • The sendWhatsAppMessage() function uses Twilio’s API to send responses back to WhatsApp, chunking large messages as necessary.
    • generateContentFromGemini() invokes the Python script with the prompt text, receives the generated response, and sends it back to the user via WhatsApp.

Step 3: Handle Message Responses Using Vertex AI in Python

Our response.py Python script manages the core logic for generating responses:

  1. Define Prompt and Response Settings: The script initializes Vertex AI and loads the Gemini model with our OB-GYN assistant prompt. It uses SafetySetting configurations to ensure responses are appropriate and culturally sensitive.

  2. Generate Responses: multiturn_generate_content() takes the user’s input, generates a response, and writes it to an output file.

  3. Run and Return: The PHP script reads the response from the output file and sends it to the user via Twilio’s WhatsApp API.

This setup enables the WhispHer chatbot to interact seamlessly on WhatsApp, providing users with general health information while maintaining privacy, sensitivity, and cultural respect. For further configuration details, refer to our GitHub repository.

Challenges we ran into

We faced several challenges during WhispHer’s development. First, setting up the WhatsApp Business API required verifying our business with Meta, which involved local government registration and complex verification processes. Due to these hurdles, we opted to use Twilio's default sandbox for initial testing.

We also needed to adapt our code to handle long responses, as Twilio enforces a 1024-character limit per message, requiring us to split messages into chunks. Lastly, integrating our PHP bot with Vertex AI presented compatibility issues, as Vertex AI relies on Python libraries. We addressed this by passing prompts to a Python script, which generates responses in a text file that our PHP bot can read and send back to users.

Accomplishments that we're proud of

We’re incredibly proud of what we’ve accomplished together as friends, dedicating our time and energy to build something that can truly help women. From configuring the Gemini model to be a supportive and accurate OB-GYN assistant to integrating it with WhatsApp, we’ve created a confidential, judgment-free space for young women to ask questions and receive reliable information. We overcame technical challenges like handling long message responses and connecting our PHP bot with Vertex AI, proving that with teamwork and persistence, we could bring WhispHer to life. Knowing that our work can make a difference in people’s lives, especially for women in areas with limited access to health information, is deeply meaningful to us.

What we learned

Throughout WhispHer's development, we learned a lot about the complexities of building a chatbot that combines technical functionality with cultural sensitivity. Setting up a WhatsApp Business API taught us the complexity of business verification with Meta, especially the local government registration requirements needed to move from sandbox testing to a live environment. We also gained hands-on experience with Twilio’s messaging constraints, adapting our code to chunk long responses for seamless interaction. On the technical side, we learned how to bridge different programming environments, integrating PHP and Python to run Vertex AI effectively within a PHP-based bot. Most importantly, we deepened our understanding of designing AI prompts that are not only accurate but also empathetic and respectful, reflecting the cultural nuances of our target users.

What's next for WhispHER: A Confidential Digital Space for Women's Health

Next, we’re planning to establish WhispHer as an official business by completing necessary legal documentation. Additionally, we’re excited to partner with local nonprofits in Sub-Saharan Africa to pilot WhispHer and assess its impact on girls' education and health outcomes in the near future. By working directly with communities, we hope to refine and enhance WhispHer's effectiveness and ensure it serves as a valuable, accessible resource for women and young girls navigating their health and well-being.

Built With

Share this project:

Updates