Skip to content

Automate Your Content Writing Workflow With Cloudinary and ChatGPT

AI and ChatGPT have taken the world by storm. Now we can leverage existing Cloudinary AI technology and add ChatGPT to automate our production workflow to write copy, product descriptions, and more.

Whether used for marketing, creative, or even technical purposes, the only limit is your imagination.

Let’s create one possible workflow; an automated copywriting service that uses ChatGPT to write a short marketing summary about a photo when it is uploaded to Cloudinary. We can also include the option to add more information to each prompt alongside the fully automated approach that requires no input. Let’s also update the photo metadata to store our newly written copy for future use.

To start, we’ll upload a photo to Cloudinary using the Node SDK and utilize the Cloudinary AI Content Analysis add-on to store our photo in Cloudinary and receive a short AI-generated caption. 

To receive a caption, let’s add detection:"captioning" to the upload parameters.

async function uploadImage() {

  try {

    const uploadResult = await cloudinary.uploader.upload("assets/images/shoes.jpg", { detection: "captioning" });

    caption = uploadResult.info.detection.captioning.data;

    imageURL = uploadResult.secure_url;

    useCaption(caption, imageURL);

  } catch (error) {

    console.error(error);

  }

}Code language: JavaScript (javascript)


We’ll use this sample picture of a pair of shoes:



The Cloudinary AI Content Analysis add-on returns the caption:

The image features a pair of purple and white sneakers.

Next, we’ll feed this caption to ChatGPT as well as any additional information we’d like to include and receive the marketing copy back. 

async function APIcall(description) {

  const openai = new OpenAI({

    apiKey: process.env.OPENAI_API_KEY

  });

  const chatHistory = [];

  do {

    const user_input = readlineSync.question(`Your picture appears to be ${description}, add more information? If you're happy with the prompt, just submit: `);

    const messageList = chatHistory.map(([input_text, completion_text]) => ({

      role: input_text === "user" ? "user" : (input_text === "system" ? "system" : "assistant"),

      content: input_text,

    }));

    messageList.push({ role: "system", content: "You are an amazing marketing creative, please use the following description of an image to write a short product summary. Make sure the post only uses factual information and is 50 words or less, is engaging, creative and ultimately makes the reader want to buy the product

" }); // Add system prompt

    messageList.push({ role: "user", content: `The default description is: "${description} ${user_input.length > 1 ? `and I'd like to add the following, ${user_input}` : ""}` }); // Include description in user input

    try {

      const GPTOutput = await openai.chat.completions.create({

        model: "gpt-3.5-turbo",

        messages: messageList,

      });

      const output_text = GPTOutput.choices[0].message.content;

      console.log("Your photo URL:", imageURL, "Your caption:", output_text);

      chatHistory.push([user_input, output_text]);

    } catch (err) {

      console.error(err);

    }

  } while (readlineSync.question("\nWould you like to add anything to the post? (Y/N)").toUpperCase() === "Y");

}Code language: PHP (php)

ChatGPT without additional information returns the following marketing copy:

Step up your style game with our eye-catching purple and white sneakers! These shoes are designed for both comfort and fashion, making them the perfect addition to any outfit. Don’t miss out on the chance to make a bold statement with your footwear choice!!

This is a great placeholder, but we can add more info. Let’s talk about info about pricing and features. Let’s add: “They cost $200, and are perfect for playing basketball.” This could also be stored in the asset’s metadata and be fully automated:

Elevate your game with these $200 purple and white basketball sneakers. Designed for performance and style, this dynamic duo will have you dominating the court in both comfort and flair. Perfect for all your hoop dreams! #GameOn #HoopsHighFashion

Once we’re happy with the product description, let’s save this info to the asset’s metadata.

cloudinary.v2.uploader.update_metadata(output_text, public_id, options).then(callback);Code language: CSS (css)

Integrating Cloudinary with ChatGPT revolutionizes how we handle image uploads and content creation. This workflow automates the generation of engaging marketing copy, streamlining your production process with Cloudinary’s AI-driven image analysis and ChatGPT’s creative writing.

Stay ahead in content creation. Visit the Cloudinary AI page or contact Cloudinary today to transform your content creation workflow.

The full code is available here.

Back to top

Featured Post