Lifeline Support
Tags: devchallenge, twiliochallenge, ai, twilio
Published: 2024-06-24 04:43:49

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

## What I Built
In a world where mental health issues are becoming increasingly prevalent, our mission is to offer a safe, supportive, and non-judgmental space for individuals to share their struggles and receive immediate, compassionate guidance.

I would have liked to have had something like this on hand; some years ago. Also, the inspiration comes from the lyrics of this song: Logic - 1-800-273-8255

Harnessing the capabilities of Flask for our web framework, Twilio for seamless voice and SMS communication, and the advanced language models from OpenAI, I have created a tool that listens, understands, and responds with empathy and care.

**Features:**
1. Real-time voice Emotional Support: Users can reach out at any time by **calling** a dedicated number, where they are greeted by a responsive and empathetic voice ready to listen and help.
2. Supportive and Non-judgmental: Every interaction is crafted to be positive and supportive, creating a safe space for users to open up about their feelings.
3. Summarizing Advice: If a user decides to end the conversation, the chatbot provides a summarized advice via **SMS**, ensuring the user has a tangible reminder of the support received.

The system looks like this, I developed a microservice to handle the real time interaction and logic:

![System Architecture](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d54tgtia93wijz4qsmq3.png)

Inside de service, there is a graph of LLMs collaborating to produce a helpful system:

![Service flow](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hjs3u8tqrfxr0a01ll4y.png)

## Demo

[Code](https://github.com/Magody/TwilioLifeLineSupport/tree/main): https://github.com/Magody/TwilioLifeLineSupport/tree/main

{% embed https://drive.google.com/file/d/18sTIw3wWpvZvecz1zeyJX45Z4bKBcRsa/preview %}

{% embed https://drive.google.com/file/d/1BypmvvApB5jOd4fEONuuZum9oe4jl3xp/preview %}

If you want to try it, you probably want to call to: +16183270085. SMSs only are enabled geographically on: Canada, US, Mexico, Ecuador, Colombia, Chile. In https://console.twilio.com/us1/develop/sms/settings/geo-permissions

## Twilio and AI

**Twilio**
A. Voice Communication:

- Voice Calls
- Twilio Voice Response (TwiML): I utilized Twilio’s Voice Response capabilities to handle incoming calls.

B. SMS Communication:

- Sending Summaries: The system uses Twilio to send a summarized SMS containing the key points of the advice provided.
- Follow-Up Messages: Twilio’s SMS service is also used to send follow-up messages, providing additional resources or encouragement as needed.

**AI Integration**

A. Natural Language Processing (NLP):

- Understanding User Input: OpenAI’s language models enable the chatbot to accurately understand and process the user’s spoken words.
- Generating Compassionate Responses: The AI generates responses that are compassionate and empathetic.

B. Context-Aware Conversations:

- Maintaining Continuity: The AI keeps track of the conversation’s context by storing previous interactions in text files. 
- Handling Crisis Situations: The AI can recognize when a user might be in crisis and responds with appropriate, comforting messages, encouraging the user to seek professional help if necessary.

## Additional Prize Categories

I think the projects is in the following categories
- Twilio Times Two: The project uses 2+ Twilio APIs (Call, SMS).
- Impactful Innovators: The project drives positive social impact.