<msc-ai-shopping-assistant /> is a is a web component based on Chrome Built-in AI Prompt API. Users could use <msc-ai-shopping-assistant /> to connect with Gemini Nano to gather rich and amazing purchase experience.
npm install msc-ai-shopping-assistant
<msc-ai-shopping-assistant /> is a is a web component based on Chrome Built-in AI Prompt API. Users could use <msc-ai-shopping-assistant /> to connect with Gemini Nano to gather rich and amazing purchase experience.
<msc-ai-shopping-assistant /> is a web component. All we need to do is put the required script into your HTML document. Then follow <msc-ai-shopping-assistant />'s html structure and everything will be all set.
- Required Script
``html`
type="module"
src="https://unpkg.com/msc-ai-shopping-assistant/mjs/wc-msc-ai-shopping-assistant.js">
- Structure
Put <msc-ai-shopping-assistant /> into HTML document. It will have different functions and looks with attribute mutation.
`html`
<msc-ai-shopping-assistant /> could also use JavaScript to create DOM element. Here comes some examples.
`html`
Developers could apply styles to decorate <msc-ai-shopping-assistant />'s looking.
`html`
Otherwise, developers colud also modified <msc-ai-shopping-assistant />'s appearance by data-appearance.
- light: light mode.dark
- : dark mode.device
- : apply system setting.
`html`
>
<msc-ai-shopping-assistant /> supports some attributes to let it become more convenience & useful.
- aiconfig
Set aiconfig as <msc-built-in-ai-prompt />'s session create parameters.
`html`
>
- placeholder
Set placeholder for user input field.
`html`
>
- recommendproducts
Set recommendproducts for recommand products. AI will analysis user prompt for purchanse intent. Once true, <msc-ai-shopping-assistant /> will dispatch event with several keywords.
`html`
>
) |※ productRecommend()'s parameter -
data should be the following structure:`json
{
"content": "message you like to show",
"listings": [
{
"url": "pruduct link",
"title": "product title",
"description": "product description",
"thumbnail": "thumbnail url",
"price": "product price"
"action": "call to action content"
},
...
]
}
`Events
| Event Signature | Description |
| ----------- | ----------- |
| msc-ai-shopping-assistant-purchase-intent | Fired when AI analysis user's prompt has purchase intent. Developers could gather clues information from event.detail. |※ event.detail:
`json
{
"clues": {
"name": "emmashop 樂福鞋",
"category": "樂福鞋",
"requires": "",
"price": "<1000",
"quantity": 1,
"scenario": "",
"synonyms": [],
"size": 38.5,
"color": "",
"brand": "emmashop",
"used": false
}
}
``