DEV Community

Cover image for 'memba?: Twilio & Vertex AI SMS Reminder System for Seniors who don't 'memba.
richardevcom
richardevcom

Posted on • Originally published at Medium

'memba?: Twilio & Vertex AI SMS Reminder System for Seniors who don't 'memba.

Image description
✨ 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. 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.

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.
Enter fullscreen mode Exit fullscreen mode
  1. Vertex AI then translates the extracted information into a structured JSON format like this:
{
   "reminder_text": "take medicine",
   "reminder_datetime": "2024-06-24T18:00:00.000Z"
}
Enter fullscreen mode Exit fullscreen mode
  1. 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).

  2. 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.

  3. 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?

Demo

  • Send your SMS reminder (for example, Remind me to take medicine on 24nd June 18:00) to +44 7822 021078.

⚡ We bravely topped up our Twilio account.

  • You can also fork our solution from here: richardevcom/memba
  • Check out our landing page (yeah, because why not?): 'memba?
  • Here is a quick demo video:

🐞 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

Top comments (10)

Collapse
 
softwaredeveloping profile image
FrontEndWebDeveloping

Good work.

Collapse
 
richardevcom profile image
richardevcom
Collapse
 
softwaredeveloping profile image
FrontEndWebDeveloping

Thank you! I also messaged you on discord. I'm @ben. 😊

Thread Thread
 
richardevcom profile image
richardevcom

I'll gladly connect. Ask anything :)

Thread Thread
 
softwaredeveloping profile image
FrontEndWebDeveloping

So are you looking to be a mentor?

Thread Thread
 
richardevcom profile image
richardevcom

Haha, no - not at the moment, but I'm always happy to connect with fellow devs.

Thread Thread
 
softwaredeveloping profile image
FrontEndWebDeveloping

That makes sense. 😀

Collapse
 
richardevcom profile image
richardevcom • Edited

Shoutout to @isitayush 💜. Collaboration lovestory irl.

Collapse
 
isitayush profile image
Ayush Gupta

Thank you Richard! Thanks for all the hardwork you put into this. This was awesome. 💙🔥

Collapse
 
richardevcom profile image
richardevcom • Edited

Thank you brother for night-shifts. I really enjoyed overcoming architecture difficulties on Google Cloud side.