1. What's GPT and why use davinci003 instead of ChatGPT?
2. Step-by-step guide to integrating Shopify API and OpenAI API
3. Setting up the data workflow
4. Best practices for prompting product descriptions
5. Prompt templates for product descriptions
6. Conclusion: It's all about prompting
Are you tired of manually writing product descriptions for your Shopify store? Have you considered automating the process but aren't sure where to start? In this blog post, we'll show you how to create your own Shopify to GPT automation for generating product descriptions with the power of natural language generation (NLG).
Not using Shopify? No problem! This process can be applied to any other shop system you might be using. We'll cover the basics of setting up the automation and how to write effective prompts for GPT to generate accurate descriptions.
Understanding which kinds of prompts work well for certain kinds of products or text formats is important for achieving quality results. We'll walk you through best practices for prompt writing, so you can create your own prompts that work well for your specific product offerings.
Finally, we'll provide you with ready-to-use Python code for pulling data from Shopify, prompting GPT, and sending the generated text back to your Shopify store. By the end of this blog post, you'll have the knowledge and tools to automate the process of writing product descriptions, saving you time and effort in the long run.
Davinci003 and ChatGPT are both large language models developed by OpenAI that can be used for a variety of natural language processing tasks. While they share many similarities, there are also some differences that could make one more suitable than the other depending on the specific use case. Here are a few pros and cons to consider when comparing davinci003 and ChatGPT: Watch our webinar recording
Among a variety of reasons, including cost and ease of integration, we had ultimately decided to use davinci003 (GPT-3) as our model of choice.
The video covers following reasons:
Other sources to be considered:
If you're curious to see the live product description generation, feel free to keep watching the video. In the next chapters we are going to cover some implementation details that you're going to need if you want to set this up for yourself.
A documentation of OpenAI's list of models can be found here: OpenAI API Models
Nowadays, there is also the option to use Python Frameworks, such as LangChain or GenossGPT to flexibly exchange models endpoints without having to rely on OpenAI.
Furthermore, Shopify has announced and released their own in-platform function to create AI-generated product descriptions which they had announced in their Winter '23 Edition - check it out.
The issue with their in-platform feature? It doesn't really scale since you can only manually apply their generative AI for one product at the time.
First of all, we need to set up a few prerequisites in order to integrate with Shopify's API.
We suggest to follow along Shopify's guide on setting up a custom app in your Shopify store.
Once that is done, go to your app settings and allow following Admin API access scopes:
Additionally, we need to generate an API key in the tab "API credentials" that we are later going to use for accessing Shopify API endpoints. Later, we are primarily going to use Shopify's Products API as well as their ProductsListing API to retrieve and update product information.
At the same time, we are also going to require an OpenAI API key in order to send prompts to their large language models. API keys can be generated and accessed under https://platform.openai.com/account/api-keys once you're logged in with your user account.
Alright, we have our API keys set up in order to establish a connection between our shop data and OpenAI. What's left is to come up with a few Python code snippets to create that connection. If you're using a different content management system the code will need some tweaking.
As for accessing our list of products we integrated Shopify's ProductListings API via DataCater's REST source connector. Since we want to avoid continuously re-generating texts or having to manually trigger the process, DataCater is the optimal choice. By capturing changes in the CMS we can identify the right timing to refresh our product descriptions based on updates of relevant data fields (Read more on change data capture).
The convenient part? DataCater pipelines also allow executing custom Python functions. The process goes as follows:
Here are the required code snippets:
Snippet 1 - Prompt davinci003
Snippet 2 - Update 'body_html' of a Shopify product
Unlike the second snippet, the first one can be used independant from your shop system. The only variable that needs to be provided by you is the content of 'prompt'.
After we've set up our API endpoints and adjusted respective code snippets to our shop system or CMS, what's left is to instantiate said pipeline.
Using DataCater's Pipeline Designer, this is a no-code task that anyone with a little bit of technical background can achieve. Of course, the shown Python code in the previous chapter would also work on your local machine, if you're running them from a Python script.
Now, what's left is to build the right prompts that yield the best results when it comes to eCommerce product descriptions.
You might wonder how "best" is defined in this case.
There are many factors to good product descriptions, such as sentence length, story and structure, readability, highlighting customer benefits and much more. For fashion product descriptions we recommend reading our 10 Fashion Copywriting Tips blog post.
If you're looking to generate oontent for different products, such as home appliances, DIY articles, beauty products or other industries, don't worry. Each industry has their own requirements that can be fulfilled by building the right prompt.
We recommend jumping straight to our webinar's section where we discuss tips on prompt building and how to restrict certain outputs (timestamp 43:13 of the above linked YouTube video). Another helpful tool is AIPRM, a browser extension with helpful prompt templates.
A thumb of rule is: Prompts with high information density and clear directives yield better outputs. Thus, you should focus on:
Pay attention to these tips and your output quality will skyrocket.
Did you think we would leave you hanging with just a few best practice tips? Of course, we are going to provide a few generally applicable templates that you can adjust towards your needs.
In case you don't have any product data - besides the product name or title, you could go for something like this:
"Could you please write me a product description for {title of product}?”
Or if you need the description for different channels, such as Amazon, you could add:
"The output should be three to five bullet points."
Now, let's assume you have some product data. Play around by adding those features to your prompts, e.g.:
“Please write me a product description for {product name} by {brand}. It should be written for customers in the luxury segment and highlight the product’s {feature_list} features.”
The good part is: Since we can build those prompts in Python or any other programming language, we can dynamically leave out or add parts to our prompts based on missing or available attributes. No product database is perfect and we need to work with what we've got.
It's also very common to have a less structured product database. Not everyone owns or maintains a PIM system with a single data field for each product feature. Sometimes they are a bit mixed up, especially when it comes to marketplace sales. For these cases, we might want to try something more complex:
“Can you please generate a product description for a {product name} by {brand} with {feature1}, {feature2}, {feature3} and {feature4}? The description should contain a {50} characters title, a {80-120} words introduction and two {100 words} each subsections. The first section dealing with {feature1} and {feature2}. The second section dealing with {feature3} and {feature4}. {...}”
Curious about the outputs and results? Have a look at our webinar recording together with DataCater and convince yourself.
We didn't really find any useful resources around building eCommerce product description prompts. Feel free to reach out to us if you need any assistance or if you want us to add more examples!
We hope that you enjoyed our webinar and/or blog post read.
In conclusion, automating the process of generating product descriptions can save significant time and effort for eCommerce businesses. This data workflow, which utilizes GPT language models, can be applied to any shop system or database.
However, the quality of output depends heavily on the quality of the input data and the effectiveness of the prompts used. Writing effective prompts tailored to specific product offerings and data structures is crucial for achieving high-quality output.
By following the guidelines presented in this blog post and paying close attention to input data quality, everyone can develop a reliable and effective data workflow for generating product descriptions that meets their specific needs.
We can also recommend using tools that help with AI prompting, such as AIPRM.