Text Suggestions API از ابزارهای هوش مصنوعی مولد Product Studio API برای تولید و بهینه سازی عناوین و توضیحات محصول استفاده می کند. میتوانید از آن برای بهبود تعامل و تبدیل مشتری و سادهسازی فرآیند مدیریت و بهروزرسانی اطلاعات محصول استفاده کنید. ویژگی های Product Studio API می تواند به شما کمک کند عملکرد خرده فروشی خود را بهینه کنید.
با استفاده از API چه چیزی می توانید ایجاد کنید؟
Text Suggestions API به شما کمک می کند کارهای زیر را انجام دهید:
- عناوین و توضیحات محصول پیشنهادی بر اساس تصویر محصول و/یا ویژگیهای محصول شما.
- عناوین بهینه شده برای سئو برای محصولات شما
- عناوین قالب بندی شده سفارشی برای محصولات شما
- توضیحات محصول از فید محصول شما
همچنین میتوانید لحن صدا را برای توضیحات مشخص کنید و در تمام لیستهای محصولات خود یکنواختی را حفظ کنید.
شروع سریع
روش GenerateProductTextSuggestions
می تواند عناوین و توضیحات محصول را با استفاده از اطلاعات محصول شما ایجاد یا بهینه کند.
API می پذیرد:
- ویژگی های محصول (فرهنگ JSON): یک شی JSON حاوی ویژگی های محصول (مانند،
{"title": "White Tee", "brand": "MyBrand", "size": "XL"}
) - تصویر محصول: یک URI که به تصویر محصول اشاره میکند (مانند
{"uri": "https://my-store.com/img/1.png"}
) - گزینههای قالببندی عنوان : پارامترهایی برای سفارشیسازی تولید عنوان، از جمله:
-
attribute_separator
: جداکننده بین صفت ها را مشخص می کند. -
target_language
: زبان خروجی را تنظیم می کند. -
attribute_order
: ترتیب صفات را در عنوان تولید شده مشخص می کند.
-
- مثالهای برچسبگذاری دادهها : نمونهای از نحوه ایجاد عنوان از توضیحات را ببینید.
- شناسه گردش کار (
output_spec.workflow_id
) : فیلدworkflow_id
در شیoutput_spec
نوع تولید متن را تعیین میکند:-
title
: عنوان محصول را تولید یا بهینه می کند. -
description
: توضیحات محصول را ایجاد یا بهینه می کند. -
tide
: عنوان و توضیحات محصول را ایجاد یا بهینه می کند.
-
نمونه ها
موارد زیر نمونههایی با استفاده از API برای تولید یا بهینهسازی عنوان یا توضیحات یا هر دو از ورودیهای داده محصول مختلف است. ما همچنین خطاها و مسائل رایج و راه حل های آنها را ارائه می دهیم.
تولید عنوان بهینه شده
مثال نشان می دهد که چگونه می توان یک عنوان بهینه تولید کرد.
درخواست کنید
بدنه درخواست حاوی اطلاعات محصول برای بهینه سازی عنوان است. در اینجا نمونه ای از ساختار درخواست آورده شده است:
POST https://merchantapi.googleapis.com/productstudio/v1alpha/accounts/{ACCOUNT_ID}:generateProductTextSuggestions
{
"product_info": {
"product_attributes": {
"title": "Nike Mens shoes",
"description": "Give strength to your step with the Nike Air Zoom Pegasus 38 shoe for Men with shoe size 12. Ensuring the fit is loved by the runners. This shoes comes in Blue color.",
"brand": "Nike"
}
},
"output_spec": {
"workflow_id": "title"
}
}
پاسخ
شما می توانید انتظار پاسخی مانند
{
"title": {
"text": "Nike Mens shoes Air Zoom Pegasus 38 Running Shoes, Blue, Size 12"
},
"metadata": {
"metadata": {
"attributes": {
"color": "Blue",
"size": "12",
"product": "Running shoes",
"model": "Air Zoom Pegasus 38"
},
}
}
}
یک عنوان فقط از یک تصویر ایجاد کنید
مثال نشان می دهد که چگونه می توان یک تصویر محصول ارائه داد و عنوانی بهینه تولید کرد.
درخواست کنید
POST https://merchantapi.googleapis.com/productstudio/v1alpha/accounts/{ACCOUNT_ID}:generateProductTextSuggestions
{
"product_info": {
"product_image":{
"uri": "https://cdn.shopify.com/s/files/1/0653/5879/0892/products/1672082339438_550x825.jpg?v=1672082415"
}
},
"output_spec": {
"workflow_id": "title",
"attribute_separator": "-"
}
}
پاسخ
{
"title": {
"text": "Rustic Ceramic & Leather Leaves Necklace"
},
"metadata": {
"metadata": {
"attributes": {
"material": "Rustic Ceramic & Leather",
"pattern": "Leaves",
"product": "Necklace"
},
}
}
}
یک عنوان از توضیحات ایجاد کنید
این مثال نحوه ارائه توضیحات محصول و ایجاد عنوان بهینه را نشان می دهد.
درخواست کنید
POST https://merchantapi.googleapis.com/productstudio/v1alpha/accounts/{ACCOUNT_ID}:generateProductTextSuggestions
{
"product_info": {
"product_attributes": {
"description": "selling size 12 nike dunks. oh they are red by the way!"
}
},
"output_spec": {
"workflow_id": "title",
}
}
پاسخ
{
"title": {
"text": "Nike Dunks Red Size 12"
},
"metadata": {
"metadata": {
"attributes": {
"brand": "Nike",
"color": "Red",
"size": "12",
"product": "Dunks"
},
}
}
}
بهینه سازی عناوین از یک عنوان و توضیحات (همراه با مثال سفارشی)
در این مثال، ویژگیهای محصولی را که میخواهیم هوش مصنوعی شناسایی کند و ترتیب صفت را در خروجی مشخص کند، مشخص میکنیم.
درخواست کنید
POST https://merchantapi.googleapis.com/productstudio/v1alpha/accounts/{ACCOUNT_ID}:generateProductTextSuggestions
{
"product_info": {
"product_attributes": {
"title": "Volumizing & Lengthening Mascara - Dark Brown",
"description": "This high-impact mascara delivers both voluptuous volume and dramatic length without clumping or smudging.",
"brand": "Luxe Beauty"
}
},
"output_spec": {
"workflow_id": "title"
}
"title_examples": [
{
"product_info": {
"title": "Lash Paradise Volumizing & Lengthening Mascara - Waterproof - Blackest Black",
"colour": "Black"
},
"title_format": "product",
"category": "mascara",
"final_product_info": {
"product": "Mascara",
"brand": "Lash Paradise",
"mascara_type": "Volumizing & Lengthening",
"colour": "Blackest Black",
"waterproof": "Waterproof",
}
},
{
"product_info": {
"title": "Hypnose Drama Instant Full Body Volume Mascara - Black",
"colour": "Black"
},
"title_format": "product",
"category": "mascara",
"final_product_info": {
"product": "Mascara",
"brand": "Hypnose",
"sub_brand": "Drama",
"mascara_type": "Full Body Volume",
"colour": "Black",
"eye_lash_type": "All lash types"
}
}
]
}
پاسخ
{
"title": {
"text": "Luxe Beauty Dark Brown Volumizing & Lengthening Mascara"
},
"metadata": {
"metadata": {
"attributes": {
"brand": "Luxe Beauty",
"colour": "Dark Brown",
"mascara_type": "Volumizing & Lengthening",
"product": "Mascara"
},
}
}
}
تولید توضیحات از یک عنوان
این مثال نحوه ارائه عنوان محصول را نشان می دهد و از API درخواست می کند تا توضیحات محصول مربوطه را ایجاد کند.
درخواست کنید
POST https://merchantapi.googleapis.com/productstudio/v1alpha/accounts/{ACCOUNT_ID}:generateProductTextSuggestions
{
"product_info": {
"product_attributes": {
"title": "Rustic Ceramic & Leather Leaves Necklace",
}
},
"output_spec": {
"workflow_id": "description"
}
}
پاسخ
{
"description": {
"text": "Rustic Ceramic & Leather Leaves Necklace is a beautiful necklace made from high-quality ceramic and leather. It features a unique design that is sure to turn heads.
"
},
}
ایجاد عنوان و توضیحات از ویژگی های محصول (مانند نام تجاری و رنگ)
این مثال ارائه ویژگی های محصول را برای ایجاد عنوان و توضیحات محصول بهینه نشان می دهد.
درخواست کنید
POST https://merchantapi.googleapis.com/productstudio/v1alpha/accounts/{ACCOUNT_ID}:generateProductTextSuggestions
{
"product_info": {
"product_attributes": {
"brand": "Mr. Beast",
"color": "purple",
},
"product_image":{
"uri": "https://mrbeast.store/cdn/shop/files/0015dlv_0000_327.jpg?v=1702754475&width=500"
}
},
"output_spec": {
"workflow_id": "description"
}
}
پاسخ
{
"title": {
"text": "Pajamas - Mr. Beast | Purple"
},
"description": {
"text": "Slip into the ultimate comfort and style with these Mr. Beast pajamas in a vibrant shade of purple. Crafted from the softest materials, these pajamas will envelop you in a cozy embrace, ensuring a restful night's sleep. The shorts feature a relaxed fit, allowing for easy movement, while the top boasts a classic design with a comfortable neckline. Whether you're lounging at home or drifting off to dreamland, these Mr. Beast pajamas are the perfect choice for a peaceful and stylish slumber."
},
}
پشتیبانی از زبان هدف
این فیلد زبان متن توضیحات تولید شده در پاسخ API را مشخص می کند. شما می توانید target_language
به عنوان بخشی از پارامترهای output_spec
اضافه کنید:
{
"output_spec": {
"target_language": "language"
}
}
مقادیر نمونه:
"korean" (Korean)
"english" (English)
"spanish" (Spanish)
"french" (French)
درخواست نمونه
POST https://merchantapi.googleapis.com/productstudio/v1alpha/accounts/{ACCOUNT_ID}:generateProductTextSuggestions
{
"product_info": {
"product_attributes": {
"title": "Granos de café negro",
"description": "Los granos de café negro en California",
"brand": "Parfums de Paris",
"scent": "Floral",
},
"product_image":{
"uri": "https://mrbeast.store/cdn/shop/files/0015dlv_0000_327.jpg?v=1702754475&width=500"
}
},
"output_spec": {
"workflow_id": "description",
"target_language": "japanese",
"attribute_order": ["scent", "product"],
"tone": "playful",
}
}
پاسخ
{
"description": {
"text": "カリフォルニアの黒いコーヒー豆は、あなたの鼻をくすぐる、甘く、フローラルな香りです。この香りは、コーヒー豆の豊かな香りと、ジャスミンとバラの繊細な花の香りをブレンドしたものです。カリフォルニアの黒いコーヒー豆は、あなたの家を居心地の良いカフェに変え、あなたをリラックスした気分にさせてくれるでしょう。この香りは、コーヒー好きにも、フローラルな香り好きにも最適です。カリフォルニアの黒いコーヒー豆で、あなたの家を幸せな香りで満たしましょう!."
},
}
شخصی سازی آهنگ صدا برای نسل توضیحات
برای کمک به ایجاد برند خود و متمایز کردن فروشگاه آنلاین خود از سایرین، می توانید لحن صدای توضیحات تولید شده خود را شخصی سازی کنید. Text API دو گزینه ارائه می دهد:
- انتخاب آهنگ از پیش تعریف شده: می توانید از لیستی از آهنگ ها برای ایجاد توضیحات جدید انتخاب کنید. این لیست شامل این سبک های لحن است:
- پیش فرض: ساده، واضح و زیبا.
- بازیگوش: سبک دل، با استفاده از زبان مثبت، شوخی (جوک، جناس) و اغراق (بدون کنایه، کنایه یا شکلک).
- رسمی: انگلیسی استاندارد، گرامر مناسب، جملات کامل، بدون زبان عامیانه یا انقباض.
- متقاعد کننده: منطقی، مختصر، و استدلال محور برای متقاعد کردن خواننده.
- مکالمه: دوستانه، آسان برای درک، زبان روزمره.
- لحن خاص برند: می توانید توضیحات موجود یا سایر دارایی های متنی را در لحن صدای برند خود ارائه دهید. مدل هوش مصنوعی مولد لحن متن را تجزیه و تحلیل میکند و یک "توصیف سبک نوشتاری" را با توجه به این جنبهها ایجاد میکند:
- رسمی (مانند رسمی، گاه به گاه)
- پرحرفی (مانند، مختصر، بسیار پرمخاطب)
- لحن (مانند، حرفه ای، آموزنده، مثبت، متقاعد کننده)
- ساختار جمله (مانند "جمله ساده با چند حرف ربط")
- بیشترین کلمات و عبارات استفاده شده
کتابخانه های مشتری
توصیه می کنیم برای ارسال درخواست های خود از کتابخانه های مشتری استفاده کنید. ما کتابخانه های مشتری را با شما به اشتراک خواهیم گذاشت که می توانید آنها را در پروژه Maven خود نصب کنید.
نمونه کد
روش احراز هویت خود را انتخاب کنید و این نمونه کد را با استفاده از این دستورالعمل ها تنظیم کنید. در اینجا نمونه ای وجود دارد که می توانید از آن برای ایجاد پیشنهادات متنی استفاده کنید.
جاوا
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.merchant.productstudio.v1alpha.GenerateProductTextSuggestionsRequest;
import com.google.shopping.merchant.productstudio.v1alpha.GenerateProductTextSuggestionsResponse;
import com.google.shopping.merchant.productstudio.v1alpha.OutputSpec;
import com.google.shopping.merchant.productstudio.v1alpha.ProductInfo;
import com.google.shopping.merchant.productstudio.v1alpha.TextSuggestionsServiceClient;
import com.google.shopping.merchant.productstudio.v1alpha.TextSuggestionsServiceSettings;
import shopping.merchant.samples.utils.Authenticator;
import shopping.merchant.samples.utils.Config;
/** This class demonstrates how to generate product text suggestions. */
public class GenerateProductTextSuggestionsSample {
private static String getName(String accountId) {
return String.format("accounts/%s", accountId);
}
public static void generateProductTextSuggestions(Config config) throws Exception {
// Obtains OAuth token based on the user's configuration.
GoogleCredentials credential = new Authenticator().authenticate();
TextSuggestionsServiceSettings textSuggestionsServiceSettings =
TextSuggestionsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
String name = getName(config.getAccountId().toString());
// Calls the API and catches and prints any network failures/errors.
try (TextSuggestionsServiceClient textSuggestionsServiceClient =
TextSuggestionsServiceClient.create(textSuggestionsServiceSettings)) {
ProductInfo productInfo =
ProductInfo.newBuilder()
.putProductAttributes("title", "Mens shirt")
.putProductAttributes("description", "A blue shirt for men in size S")
.build();
OutputSpec outputSpec = OutputSpec.newBuilder().setWorkflowId("title").build();
GenerateProductTextSuggestionsRequest request =
GenerateProductTextSuggestionsRequest.newBuilder()
.setName(name)
.setProductInfo(productInfo)
.setOutputSpec(outputSpec)
.build();
System.out.println("Sending GenerateProductTextSuggestions request: " + name);
GenerateProductTextSuggestionsResponse response =
textSuggestionsServiceClient.generateProductTextSuggestions(request);
System.out.println("Generated product text suggestions response below:");
System.out.println(response);
} catch (Exception e) {
System.out.println("An error has occured: ");
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
Config config = Config.load();
generateProductTextSuggestions(config);
}
}
خطاها و مشکلات رایج
در اینجا چند مشکل رایج و راه حل های آنها آورده شده است.
اطلاعات محصول برای ایجاد پیشنهادات متنی مورد نیاز است
در صورت دریافت پیغام خطای زیر
Error message:
"error": {
"code": 400,
"message": "[product_info] Product info is required to generate text suggestions.",
"status": "INVALID_ARGUMENT",
...
}
product_info
در بدنه درخواست اضافه کنید و حداقل یکی از product_attributes
یا product_image
به درستی پر کنید.
به عنوان مثال، ارسال این پست منجر به خطا می شود.
POST https://merchantapi.googleapis.com/productstudio/v1alpha/accounts/{ACCOUNT_ID}:generateProductTextSuggestions
{
"output_spec": {
"workflow_id": "title"
}
}
حداقل یک فیلد product_info برای ایجاد پیشنهادهای متنی مورد نیاز است
این خطا
{
"error": {
"code": 400,
"message": "[product_info.product_attributes] At least one field of product_info is required to generate text suggestions.",
"status": "INVALID_ARGUMENT",
...
}
نشان دهنده این است که شما باید حداقل یک قسمت product_info
در بدنه درخواست اضافه کنید.
به عنوان مثال، ارسال این پست منجر به خطا می شود.
POST https://merchantapi.googleapis.com/productstudio/v1alpha/accounts/{ACCOUNT_ID}:generateProductTextSuggestions
{
"product_info": {
},
"output_spec": {
"workflow_id": "title"
}
}
به جای آن از چیزی مانند استفاده کنید
"product_info": {
"product_attributes": {
"description": "Selling size 12 Nike dunks. Oh they are red by the way!"
}
}
یا
"product_info": {
"product_image":{
"uri": "https://cdn.shopify.com/s/files/1/0653/5879/0892/products/1672082339438_550x825.jpg?v=1672082415"
}
}
(چیزی) در هر title_example مورد نیاز است
خطاهایی مانند چهار مثال زیر
{
"error": {
"code": 400,
"message": "[title_examples.product_info] At least one field of product_info is required in each title_example.",
"status": "INVALID_ARGUMENT",
...
}
یا
{
...
"message": "[title_examples.category] Category is required in each title_example.",
...
}
یا
{
...
"message": "[title_examples.title_format] Title format is required in each title_example.",
...
}
یا
{
...
"message": "[title_examples.final_product_info] At least one field of final_product_info is required in each title_example.",
...
}
نشان می دهد که شما یک زیر فیلد ضروری را پر نکرده اید.
به عنوان مثال، درخواست زیر یک خطا ایجاد می کند.
POST
https://merchantapi.googleapis.com/productstudio/v1alpha/accounts/{ACCOUNT_ID}:generateProductTextSuggestions
{
"product_info": {
"product_attributes": {
"description": "selling size 12 nike dunks. oh they are red by the way!"
}
},
"output_spec": {
"workflow_id": "title"
},
"title_examples": []
}
برای حل این مشکل، برای هر title_example مشخص شده در درخواست، تمام زیر فیلدهای زیر را پر کنید:
-
product_info
-
category
-
title_format
-
final_product_info
در اینجا یک مثال است که کار می کند:
{
"product_info": {
"product_attributes": {
"title": "Volumizing & Lengthening Mascara - Dark Brown",
"description": "This high-impact mascara delivers both voluptuous volume and dramatic length without clumping or smudging.",
}
},
"output_spec": {
"workflow_id": "title"
},
"title_examples": [
{
"product_info": {
"title": "Lash Paradise Volumizing & Lengthening Mascara - Waterproof - Blackest Black",
"colour": "Black"
},
"title_format": "product",
"category": "mascara",
"final_product_info": {
"product": "Mascara",
"brand": "Lash Paradise",
"mascara_type": "Volumizing & Lengthening",
"colour": "Blackest Black",
"waterproof": "Waterproof",
}
}
]
}
workflow_id پشتیبانی نشده است
این نوع خطا
{
"error": {
"code": 400,
"message": "[\u003ceye3 title='/ProductStudioTextGenerationService.GenerateProductText, INVALID_ARGUMENT'/\u003e APPLICATION_ERROR; ... ;Unsupported workflow_id: attributes. Supported workflows are: [\"title\", \"description\", \"tide\"];AppErrorCode=3;StartTimeMs=1740696804045;unknown;ResFormat=uncompressed;ServerTimeSec=0.005976589;LogBytes=256;Non-FailFast;EffSecLevel=none;ReqFormat=uncompressed;ReqID=4d1786f59faa3ea7;GlobalID=0;Server=[2002:a05:6e16:618:b0:2c2:7cfc:bebd]:14001] Invalid value",
"status": "INVALID_ARGUMENT",
...
}
از درخواستی مانند
POST https://merchantapi.googleapis.com/productstudio/v1alpha/accounts/{ACCOUNT_ID}:generateProductTextSuggestions
{
"product_info": {
"product_attributes": {
"title": "Volumizing & Lengthening Mascara - Dark Brown",
"description": "This high-impact mascara delivers both voluptuous volume and dramatic length without clumping or smudging.",
},
"output_spec": {
"workflow_id": "attributes"
}
}
درخواست workflow_id
را روی "ویژگی" تنظیم می کند، اما این فیلد تنها یکی از مقادیر زیر را پشتیبانی می کند:
- عنوان : عنوان محصول را تولید یا بهینه می کند.
- توضیحات : توضیحات محصول را ایجاد یا بهینه می کند.
- جزر و مد : عنوان و توضیحات محصول را ایجاد یا بهینه می کند.
لحن پشتیبانی نشده
یک خطای "Un Supported Tone" مانند
{
"error": {
"code": 400,
"message": "[\u003ceye3 title='/ProductStudioTextGenerationService.GenerateProductText, INVALID_ARGUMENT'/\u003e APPLICATION_ERROR; ... ; Unsupported tone: 'asdf'. Supported tones are: [\"default\", \"playful\", \"formal\", \"persuasive\", \"conversational\"];AppErrorCode=3;StartTimeMs=1740697325058;unknown;ResFormat=uncompressed;ServerTimeSec=7.45346E-4;LogBytes=256;Non-FailFast;EffSecLevel=none;ReqFormat=uncompressed;ReqID=f7d9bbbc73a1d342;GlobalID=0;Server=[2002:a05:6918:3486:b0:2bc:ccd4:79e6]:14001] Invalid value",
"status": "INVALID_ARGUMENT",
...
}
ناشی از درخواستی مانند
POST https://merchantapi.googleapis.com/productstudio/v1alpha/accounts/{ACCOUNT_ID}:generateProductTextSuggestions
{
"product_info": {
"product_attributes": {
"title": "Volumizing & Lengthening Mascara - Dark Brown",
"description": "This high-impact mascara delivers both voluptuous volume and dramatic length without clumping or smudging.",
},
"output_spec": {
"workflow_id": "description"
"tone": "cheerful"
}
}
توجه داشته باشید که tone
روی "شاد" تنظیم شده است، اما این فیلد فقط یکی از مقادیر زیر را پشتیبانی می کند:
- پیش فرض : ساده، واضح و زیبا.
- بازیگوش : سبک دل، با استفاده از زبان مثبت، شوخی (شوخی، جناس) و اغراق (بدون کنایه، کنایه یا شکلک).
- رسمی : انگلیسی استاندارد، گرامر مناسب، جملات کامل، بدون زبان عامیانه یا انقباض.
- متقاعد کننده : منطقی، مختصر، و استدلال محور برای متقاعد کردن خواننده.
- محاوره ای : دوستانه، آسان برای درک، زبان روزمره.