How I Use OpenAI’s GPT-4 To Stay In Touch With My Mum More Consistently

Using tools such as OpenAI’s GPT-4, AWS SNS, Terraform, and Kestra to stay in touch with our loved ones more regularly

Anna Geller
Better Programming

--

Diagram created using the eraser.io

In today’s fast-paced world, balancing work responsibilities, social events, and personal goals can make life feel like an overwhelming whirlwind. Amidst the hustle and bustle, one crucial aspect of our lives that often seems to slip through the cracks is staying connected with our parents. In this blog post, we’ll explore how you can leverage AI to help you consistently stay in touch with your loved ones.

Use case

I want to reach out to my mum once per week. I want to ask her how she is doing, tell her that I’m fine, remind her that she’s the best mum in the world, and tell her how much I appreciate having her in my life.

The problem is that I forget to do that sometimes. As I start taking on more responsibilities in my personal and professional life, maintaining that consistency becomes increasingly difficult.

Of course, one obvious solution would be just setting up a weekly reminder. But with many things on your plate, a reminder often is not enough — it’s better to take the first step and send an initial message. Here is a possible solution to that problem:

  • Let AI create a nice initial message asking how she’s doing in the same tone that I would write it.
  • Send that message via plain SMS and do it consistently, every Sunday.

Implementation plan

We’ll create a prompt for GPT-4 model that will create a short but unique message each time.

We’ll then use AWS SNS to send SMS messages. Finally, we’ll leverage Kestra to schedule that to run every Sunday and Terraform to manage all resources as code.

Setup

To follow along, you need to have an OpenAI API key. If you don’t have one yet, you can create it from the OpenAI account page. Then, create an .env file and paste the OpenAI API key there:

Later, we’ll also install the openai Python package within the orchestration environment.

Prompt to OpenAI’s GPT-4

Here is the entire code of the script:

If you don’t have access to gpt-4 API, you can instead set the model on line 11 to the value gpt-3.5-turbo. For this simple use case of sending an SMS, you should not see any difference in the output quality between GPT-3.5 and GPT-4.

Here is an example response:

Hi mum! Just letting you know I’m doing great. How are things with you? Miss you and sending lots of love your way! 💖

And one more:

Hi Mum! All’s good here, hope you’re well too. Let’s catch up soon! Take care, sending big hugs! 💕

You can iterate to refine the prompt so that it suits your needs. It’s helpful to provide as much information as possible about the recipient and the goal of your message. You can also experiment with the temperature configured in the script above on line 16.

Deployment

To send that message as an SMS every Sunday, you can leverage the following tools:

  • AWS SNS for SMS notifications
  • Kestra for scheduling and monitoring the process
  • Terraform to manage all resources as code.

Installation: AWS CLI, Terraform, Kestra

Make sure that your AWS CLI is authenticated with an AWS user having SNS access. Follow these instructions if you don’t have AWS CLI installed in your environment yet.

Check the Terraform CLI install guide for detailed instructions for your OS. On macOS, you can install Terraform using Homebrew:

brew tap hashicorp/tap
brew install hashicorp/tap/terraform

Then to install Kestra, run the following commands (Docker is required):

curl -o docker-compose.yml https://raw.githubusercontent.com/kestra-io/kestra/develop/docker-compose.yml
docker-compose up

The setup with Terraform: main.tf

Below is a GitHub gist that contains all resources needed for this simple project. First, we specify AWS and Kestra providers. Then, we set the relevant variables. Finally, we create an SNS SMS subscription and a Kestra flow. On line 60, the workflow defines the openai Python dependency.

The configuration above deliberately includes the entire setup within a single file to make it easier for you to reproduce it. Feel free to split variables into terraform.tfvars and separate SNS and Kestra resources into their own modules.

Deploy with Terraform from a local terminal

Run terraform apply -auto-approve from the directory where you stored the main.tf file. The CLI will prompt you to enter a phone number of a person that should receive the SMS messages, e.g., I’ll enter my mum’s mobile phone number. As soon as Terraform finishes applying changes, you should see a new flow named smsMum in your Kestra UI. To make sure it’s working as expected, trigger an execution:

Soon, you should see a similar output (with a custom message):

Schedule

We’ve triggered the workflow manually and validated that the messages are generated and sent as expected. Navigate to the schedule to validate that this process will be triggered every Sunday:

Now I can consistently stay in touch with my mum and brighten her day. 🤗

Next steps

This use case is not real. My mum doesn’t speak English, sending such messages every week at the same time would be suspicious, and the sender from SNS already spoils that the message sender is not real me. But it was used to demonstrate a simple project architecture that could be extended and applied to various use cases. The prompt could be anything, and the messages published to the SNS topic could fan out to many more destinations than just sending an SMS: it could trigger a Lambda function, put a message to an SQS queue, and more. You can join the open-source community at kestra.io/slack if you have questions about Kestra or if you want to discuss other fun use cases combining AI, serverless, and orchestration.

--

--