Shopping Muse Using React Native SDK
Powered by the Assistant endpoint, Shopping Muse provides your site visitors with a conversational product discovery experience. The API processes user inputs in real time, identifying intent and contextual cues to deliver highly relevant, personalized product suggestions.
For more information see the following:
Parameters
| Parameter | Data Structure Type | Mandatory? | Description |
|---|---|---|---|
| page | Page | Yes | Information about the current page (for example, homePage, categoryPage). Used for campaign targeting and context. |
| text | String | Yes | The userās message sent to the Shopping Muse assistant. |
| chatId | String | No | Identifier of an existing conversation. Pass this to continue a previous chat; omit it to start a new conversation. |
| pageAttributes | Map<String, PageAttribute>? | No | Additional pageālevel attributes (for example, category, user intent) used for targeting and personalization. |
| branchId | String | No | Branch identifier for multiābranch setups (stores, financial institutions, restaurants). |
| options | AssistantOptions | No | Additional configuration for the assistant request (for example, analytics or behavior flags, when available). |
Code example
async function chatWithAssistantExample() {
await assistant.chatWithAssistant({
page: Page.categoryPage({
location: 'category-page',
categories: ['kids', 'shhoes']
}),
text: 'I want to buy something nice'
})
.then((result) => {
switch (result.status) {
case 'SUCCESS':
case 'WARNING': {
const variation = result.choices?.[0]?.variations?.[0];
const data = variation?.payload?.data;
if (data) {
if (data.assistant) {
// present helper to the customer
}
if (data.chatId) {
// add chatId to the following request
}
data.widgets?.forEach((widget) => {
const title = widget.title;
console.log('Widget title:', title);
const slots = widget.slots;
if (slots) {
for (const slot of slots) {
const productData = slot.productData as DefaultRecsProductData | undefined;
console.log(productData?.group_id ?? '');
console.log(productData?.name ?? '');
console.log(productData?.url ?? '');
console.log(productData?.price ?? '');
console.log(productData?.in_stock ?? '');
console.log(productData?.image_url ?? '');
console.log(productData?.categories ?? '');
console.log(productData?.keywords ?? '');
}
}
});
}
break;
}
case 'ERROR':
// handle error
break;
}
})
.catch((error) => {
// handle error that happened during the request, like wrong parameter
});
}
``Updated 5 days ago