---
updatedAt: 2026-02-23T11:28:56.000Z
---

# Shopping Muse Using Kotlin SDK

Get response variations for Shopping Muse campaigns.

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:
>
> * [Shopping Mush API reference](https://dy.dev/dy-dev/reference/shopping-muse)
> * [Shopping Muse developer guide](https://dy.dev/dy-dev/docs/muse)

## 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).      |

## Example

```kotlin
suspend fun chatWithAssistant() {

    val result =
        DYSdk.getInstance()
            .assistant
            .chatWithAssistant(
                page =
                    Page.categoryPage(pageLocation = "category-page", categories = listOf("bla")),
                text = "I want to buy something nice"
            )

    when (result.status) {
        ResultStatus.SUCCESS,
        ResultStatus.WARNING -> {

            val variation =
                result.choices?.firstOrNull()?.variations?.firstOrNull()
                    ?: run {
                        Log.w("Assistant", "No choices/variations returned for assistant response")

                        return
                    }

            val data = variation.payload.data

            val assistant = data.assistant

            val chatId = data.chatId

            val support = data.support

            Log.d(
                "Assistant",
                "Assistant response: chatId=$chatId, assistant=$assistant, support=$support"
            )

            // Handle widgets and their product slots

            data.widgets?.forEach { widget ->
                val title = widget.title

                Log.d("Assistant", "Widget: title=$title")

                widget.slots.forEach { slot ->
                    val productData = slot.productData as? DefaultRecsProductData ?: return@forEach

                    val groupId = productData.group_id

                    val name = productData.name

                    val url = productData.url

                    val price = productData.price

                    val inStock = productData.in_stock

                    val imageUrl = productData.image_url

                    val categories = productData.categories

                    val keywords = productData.keywords

                    Log.d(
                        "Assistant",
                        "Widget product: groupId=$groupId, name=$name, price=$price, inStock=$inStock, url=$url"
                    )

                    Log.v(
                        "Assistant",
                        "Widget product details: imageUrl=$imageUrl, categories=$categories, keywords=$keywords"
                    )
                }
            }
        }
        ResultStatus.ERROR -> {

            result.error?.let { exception ->
                Log.e("Assistant", "Assistant error: ${exception.message}", exception)
            } ?: Log.e("Assistant", "Assistant error: unknown error")
        }
    }
}
```

## Shopping Muse campaign

**AssistantPayload**

| Property | Data Structure Type | Description        |
| :------- | :------------------ | :----------------- |
| **type** | SHOPPING\_MUSE      | The decision type  |
| **data** | AssistantData       | The variation data |

**AssistantData**

| Property      | Data Structure Type                               | Description                                                                                                              |
| :------------ | :------------------------------------------------ | :----------------------------------------------------------------------------------------------------------------------- |
| **assistant** | String?                                           | The assistant’s textual response for the current step in the conversation                                                |
| **widgets**   | List<[Widget](https://dy.dev/dy-dev/docs/kotlin-sdk-references#widget)>? | A list of widgets representing the structured content returned by the assistant (product lists, answer cards, and so on) |
| **support**   | Boolean?                                          | Indicates whether the assistant supports follow‑up user queries within the same session                                  |
| **chatId**    | String?                                           | The unique identifier of the current Shopping Muse conversation session                                                  |