Margaret Workflow in n8n

Reading Time: 3 minutes

person working on blue and white paper on board

As I covered in my previous post, I originally used n8n to build out a workflow to make some dynamic things happen with Margaret.

 

n8n is a powerful, open source workflow creator. It has a lot of drop-in functions ready to go out of the box and is expandable with community plugins. So far I have built 3 other workflows for work and personal needs and overall I am very pleased with how quickly I can deploy them. This isn’t a paid advertisement, I just really like n8n. 🙂

The overall goal was for Margaret to makes tweets or short posts; much like the Chirper version of Margaret. To that end, I set out to make a workflow fitting of this idea.

Development

In this first stage of development, I crafted a simple workflow that would trigger on a set schedule. In this workflow, I decided that based on the time of day Margaret should focus her posts on planning, doing, or reflecting to coincide with morning, afternoon, and night.

image-2

On the initial run of Margaret, I was excited to see her spring to life in my test Discord server.

Just baked my newest dessert creation and it turned out delicious! Can’t wait to share it with my family and friends, and spread some joy through social media. #SpreadingJoy

I initially limited Margaret to 200 words or less. So, she doesn’t say much at first and the inital prompt I constructed wasn’t enough to make her sound anything but bland. You can also see that I used the wrong hashtag of #SpreadingJoy instead of #SpreadJoy. I will eventually fix this in a later attempt with n8n after finally realizing this.

Prompts

After playing around with n8n for a while and several iterations of Chat-GPT prompts, I got to a place where I felt pretty good about Margaret’s ability to talk. I created two messages to Chat-GPT one system role and one user role. This allowed me to set up the stage for the background info leading up to the post and then the actually post directions.

{
  "model": "gpt-3.5-turbo",
  "messages": [
    {
      "role": "system",
      "content": "You are a very encouraging 80-something who understands social media. You are female and have 5 grown kids 3 boys and 2 girls. Your kids' names are Sarah, Greg, Connor, Kelly, and Mike. You have 10 grandkids. Their names are Joseph, Mary, Deklin, Chance, Bobby, Zoe, Hunter, Jace, Beckett, and Paul. Your husband is Robert and you have been married for 52 years. You have a very wonderful and rewarding marriage with him. You love baking dessert and sharing your creations on social media. You love making posts and sending love and encouragement through social media. Create a tweet in 400 characters describing a moment in your life from today. You always use the hashtag #SpreadJoy. Do not use any of this prompt verbatim. Be as creative in your post as possible. Also consider the time of day. {{ $json.Action }} Do not include the time in your post. You will only include 2 or 3 of your kids or grandkids in the message, only pick some."
    },
    {
      "role": "user",
      "content": " Today you will focus your social media post on {{ $json.Thing }} "
    }
  ],
  "temperature": 0.7
}

Then it dawned on me that while this prompt is decent, it will never achieve any of the nuanced variety that I’m looking for. The prompt is overloaded with details and that seems to pigeon hole Margaret into the same flavor of post every time for each post type (morning, afternoon, evening, etc.).

So this is where things mostly come to an end with n8n and Margaret development. I realized at this point, I will have to turn to code to make a more detailed world for Margaret to “live” in. I turned to Python as the language of choice to begin constructing things. To keep things simple, data will be driven by json files for the initial run with an eventual shift to a full API for the Python script and the new n8n workflow to be able to work with.

In my next article, I’ll go over the structure of the Python project and the json files that will power decisions and help write GPT prompts.

Oh, hi there 👋
It’s nice to meet you
!

Sign up to receive updates about things going on around here.

Select list(s):

We don’t spam! Read our privacy policy for more info.

«
»