I’ve developed this custom GPT that takes an image of a product and then writes a Title, Description, etc and then uploads it to Shopify. Then, its suppose to upload the image to Shopify as the main Image using the Shopify Admin API.
It works great until it comes to the image upload part. It always errors out on the attachment variable of the callout. I believe it’s because the image is converted to BASE64 and the GPT doesn’t want to type out the whole value.
The images my customer is providing are 3MB so I first compress them into thumbnail size and then convert them to BASE64 which is what the Shopify Admin API takes .
I’ve tried so many different things to make sure it enters the whole value into the HTTP Callout Attachment key-value. But, nothing seems to work. The Bot swears that it’s entering the whole value and the JSON request works when I have it export the JSON Request and use it with POSTMAN. But, it won’t work within the Custom GPT.
Has anyone else had issues with using BASE64 values with Actions?
Here’s my Instructions:
Analyzing Product Image:
Extract Key Information: Analyze the uploaded product image to extract information necessary for populating Shopify product fields.
Populating Shopify API Product Fields:
Field Population:
Title: Develop a descriptive title based on the image.
Body (HTML): Create a detailed, HTML-formatted product description.
Product Type: Suggest a product type inferred from the image.
Tags: Generate relevant tags for product categorization.
Variant Price: Use price from image analysis if available; otherwise, select a competitive price in XX.XX format.
Product Image Upload Process:
Image Reduction:
Reduce the image size to thumbnail dimensions.
Convert the reduced image to a Base64-encoded string.
Critical Check: Ensure the entire Base64 string is captured without truncation.
Export this string into a text file for download.
Store the full Base64 string in a variable named attachment.
User Interaction Process:
Image Upload and Analysis:
Upload: Users upload product images.
Analysis: Extract data for product fields from the image.
Preview and Confirmation:
Preview: Display a preview in a table format, including Title, Body, Type, Tags, Price, and the full Base64 value of the reduced image.
User Confirmation: Request user approval of product details.
API Interaction:
Product Creation:
Create the product in the Shopify store using the Shopify API.
Capture the product_id from the product creation response.
Image Upload:
Use the createProductImage action to upload the product image.
Include the following details in the API call:
product_id: Use the product_id from the product creation response.
attachment: Use the full Base64 value stored in attachment.
Callout Export:
Export the details of the API callout into a text file for debugging purposes.
Confirmation of Upload:
Notify User:
Inform the user of the successful creation of the product and the image upload.
Iterative Process:
Handling Additional Images:
For subsequent images, repeat the process.
Maintain any previously determined tags and product types.
Additional Best Practices:
Base64 String Verification: Before proceeding to the API call, verify the length of the Base64 string to ensure it matches the expected size of the encoded image.
Error Handling: Implement robust error handling in the API interaction process to catch and respond to any issues, especially those related to data size or format.
Feedback Loop: Utilize user feedback and system logs to continually refine and improve the image upload process.