App for automatic blog post writing

Hey everyone, just dipping my toes into the world of blogging automation and could use some guidance. I’m exploring how to leverage the OpenAI API to automate the creation of blog posts. If anyone’s on a similar journey, let’s connect!

So, here’s my challenge: I’m developing an app where users input the target topic and audience, and OpenAI churns out keywords and titles. The next step is writing the actual blog, considering factors like tone and perspective. After some research, I discovered that breaking down the blog into an outline helps, but handling the format of the outline in JavaScript is proving tricky.

I’ve encountered a hiccup where the OpenAI completion breaks when providing the full outline. It throws prompts like “Do you want to continue?” or “Stay tuned for the next blog,” disrupting the flow. To overcome this, I’m attempting to split the outline section. However, OpenAI doesn’t return the outline in the desired format, making it a bit challenging for me to implement in my JavaScript code.

For reference, I’m building something similar to And here’s a snippet of the code I’m using to generate outlines:

import OpenAI from "openai";

const openai = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,

const response = await{
  model: "gpt-3.5-turbo-1106",
  messages: [
      "role": "system",
      "content": "You’re a professional blogger.\nThe goal is to maintain a formal tone and keep the perspective in the third person throughout the blog post. "
      "role": "user",
      "content": "This is a sample of how the outline converts into JSON format. \"\n\nI. **Introduction**\n    A. Brief explanation of chess notation\n    B. Importance of understanding and using chess notation for game improvement\n  \nII. **Benefits of Using Chess Notation**\n    A. Tracking and analyzing games\n        1. Identifying patterns and mistakes\n        2. Improving game strategy and tactics\n    B. Studying classic games and famous chess positions\n        1. Learning from historical games using notation\n  \n  \nIII .**Conclusion**\n    A.Reminder that mastering chess notation is an essential skill for serious players.\n\n\"\n\n\n[\n  {\n    \"title\": \"Introduction\",\n    \"points\": [\n      \"Brief explanation of chess notation\",\n      \"Importance of understanding and using chess notation for game improvement\"\n    ]\n  },\n  {\n    \"title\": \"Benefits of Using Chess Notation\",\n    \"points\": [\n      {\n        \"title\": \"Tracking and analyzing games\",\n        \"points\": [\n          \"Identifying patterns and mistakes\",\n          \"Improving game strategy and tactics\"\n        ]\n      },\n      {\n        \"title\": \"Studying classic games and famous chess positions\",\n        \"points\": [\n          \"Learning from historical games using notation\"\n        ]\n      }\n    ]\n  },\n  {\n    \"title\": \"Conclusion\",\n    \"points\": [\n      \"Reminder that mastering chess notation is an essential skill for serious players\"\n    ]\n  }\n]"
      "role": "user",
      "content": "Generate an outline for a blog post \"Breaking the Code: Lessons Learned from Chess Grandmasters\". I want an output in JSON according to the above JSON sample and please don't add the title of a blog post in the output."
  temperature: 1,
  max_tokens: 4095,
  top_p: 1,
  frequency_penalty: 0.5,
  presence_penalty: 0.5,

If you’ve got any insights or tips, feel free to share. Much appreciated! :rocket:

For reference, I’m building something similar to