'memba?: Twilio & Vertex AI SMS Reminder System for Seniors who don't 'memba.
Tags: twiliochallenge, vertex, googlecloud, reminder
Published: 2024-06-24 18:34:03


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9y1fkegfqxux9brm9ljy.gif)
✨ As part of dev.to Twilio AI challange me and @isitayush crafted a digital guardian angel for seniors (not you... probably).

## Here's how 'memba works:

1. You simply send an SMS message to a designated Twilio phone number [+44 7822 021078](tel:+447822021078). The message should be formatted like this: `Remind me to take medicine on 24nd June 18:00`.

2. Twilio sends SMS to our Node.js/Express.js app container. 
> ⚡ This app is containerized using Docker Hub and run using Google Cloud Run (hail automation).

3. The Cloud Run application forwards the SMS content to Vertex AI (Gemini LLM), with our predefined instructions.
```txt
Functionality:Parse reminder text into JSON format.
Input:The text of the reminder and/or date, time.Output:JSON string in the format: {'reminder_text': "<text>", 'reminder_datetime': "<ISO 8601 extended format>"}.
Don't include any introduction text likt "Hello...", "Remind me to...", "Please..." in reminder_text.

Error handling:If the reminder text doesn't follow the expected format (e.g., missing date/time), return an empty JSON string {}.
If the date/time is not set or can't be parsed, return an empty JSON string {}.
If reminder_text is empty or not set, return an empty JSON string {}.
If date is set, but time is not set, use current time. If time is set, but date is not set, use current date.
Don't return the JSON string as markdown.
Do not delimit the output JSON with anything.
If reminder text contains abstract date, time meanings like "tomorrow", "next week", "next month", etc. then convert them to date, time as ISO8601 extended format - for example, "tomorrow" becomes <current_date> + 1 day or "next week" becomes <current_date> + 7 days, etc.
```

4. Vertex AI then translates the extracted information into a structured JSON format like this:
```json
{
   "reminder_text": "take medicine",
   "reminder_datetime": "2024-06-24T18:00:00.000Z"
}
```

5. We then send the JSON out to our Cloud SQL MySQL database and store it (we chose to use Prisma in our Node.js app).

6. Then a background job (we also put it directly in our Node.js app) runs every minute. This job scans the database for reminders scheduled within the next minute.

7. For identified reminders, the job triggers an SMS notification back to the senior's phone via the Twilio API precisely at the set `reminder_datetime`.

![Do you 'memba?](https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExZG1pMTE4dHRrOW5qbzBsc290Ymt4ZGxvZnJoa2Izb2tqM2g3dWRxaSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/f8c3iR9TzCCSDyIAsY/giphy.gif)

## Demo
- Send your SMS reminder (for example, `Remind me to take medicine on 24nd June 18:00`) to [+44 7822 021078](tel:+447822021078).

> ⚡ We bravely topped up our Twilio account.

- You can also fork our solution from here: [richardevcom/memba](https://github.com/richardevcom/memba)
- Check out our landing page (yeah, because why not?): ['memba?](https://memba.my.canva.site/)
- Here is a quick demo video:
{% youtube lqeuZKZNwKk %}

## 🐞 Known issues
- Our LLM is smart enough to parse data, but not smart enough to determine correct timezone from phone nr. country code. Expect your reminders to have date/time offset.

> ⚡ Many countries have multiple timezones (did you know that France has 12 timezones? 🤯) and one phone number country code - which basically leads our solution to have date/time offsets.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lx17uc59bsykh4px9ddm.png)