Shopping Assistant SDK
Chat

Chat

Overview

The Chat component is a core UI component of the Shopping Assistant SDK that renders the complete chat interface, including conversation messages, initial prompts, loading states, and message rendering. It provides a fully functional chat experience with support for user messages, AI responses, product displays, and customizable styling.

Usage

// importing component
import { Chat } from "@unbxd-ui/react-shopping-assistant-components";

Code Example

import { UnbxdShoppingAssistantWrapper } from "@unbxd-ui/react-shopping-assistant-hooks";
import { Chat } from "@unbxd-ui/react-shopping-assistant-components";
 
function ShoppingAssistantApp() {
	return (
		<UnbxdShoppingAssistantWrapper siteKey="YOUR_SITE_KEY" convStorageType="LOCALSTORAGE">
			<div className="chat-container">
				<Chat />
			</div>
		</UnbxdShoppingAssistantWrapper>
	);
}
⚠️
Note:

The Chat component must be used within the UnbxdShoppingAssistantWrapper to ensure that the component and the shopping assistant functionality work properly.

Props

InitialMessageComponent

optional
React Component
  • A custom component to display an initial welcome message when the chat loads.
  • This component appears above the chat messages and initial prompts.
  • Default Value:
const InitialMessageComponent = () => {
	return (
		<div className="initial-message-component">
			Hi there! 👋
			<br />
			I'm your Furniture Shopping Assistant, ready to help you find exactly what you're looking for. ✨ — What would you like to shop for today?
		</div>
	);
};

InitialPromptsComponent

optional
React Component
  • A custom component that displays clickable prompt suggestions to help users get started with the shopping assistant.
  • Shows predefined example questions that users can click to automatically ask the AI agent.
  • Useful for onboarding new users and showcasing the types of queries the assistant can handle.
  • Each prompt is interactive and will trigger a conversation when clicked.
  • In props it receives prompts which are the questions received from the api through questions api.
  • Default Value:
const InitialPrompts = (props: InitialPromptsProps) => {
	const {
		onPromptClick = defaultInitialPromptsProps.onPromptClick,
		prompts=[]
	} = props;
 
	const { askAgent } = useShoppingAssistant();
 
	const handlePromptClick = (prompt: string) => {
		onPromptClick && onPromptClick(prompt);
		askAgent(prompt);
	};
 
	const renderInitialPrompts = () => {
		if (!prompts) return null;
		return prompts.map((prompt: string) => <InitialPrompt prompt={prompt} onPromptClick={() => handlePromptClick(prompt)} key={prompt} />);
	};
 
	return (
		<div className="initial-prompts-container">
			<div className="initial-prompts-label">{""}</div>
			<div className="initial-prompts-wrapper">{renderInitialPrompts()}</div>
		</div>
	);
};

LoadingComponent

optional
React Component
  • A custom component to display while the AI is processing and generating responses.
  • Shows during API calls and conversation loading states.
  • Default Value:
const LoadingComponent = () => {
	return <div className="loading-component">Awaiting response...</div>;
};

UserIconComponent

optional
React Component
  • A custom icon component to display next to user messages.
  • Helps distinguish user messages in the conversation.
  • Default Value:
const UserIconComponent = () => {
	return <>Me</>;
};

AIIconComponent

optional
React Component
  • A custom icon component to display next to AI assistant messages.
  • Helps distinguish AI responses in the conversation.
  • Default Value:
const AIIconComponent = () => {
	return <>AI</>;
};

UserMessageComponent

optional
React Component
  • A custom component for rendering user messages in the chat.
  • Receives message, UserIconComponent, and optionally image as props. When visualAssistant is enabled in the wrapper, user messages can include an attached image (base64 string); pass image to show a preview or indicator in the message.
  • Default Value:
const UserMessage = ({ message, image, UserIconComponent }: UserMessageProps) => {
    return <div className="user-message-container">
        <div className="user-message-text">
            {message}
        </div>
        {image && <img src={image} alt="Attached" className="user-message-image" />}
        <div className="user-message-icon-wrapper">
            {UserIconComponent && <UserIconComponent />}
        </div>
    </div>;
};

AIMessageComponent

optional
React Component
  • A custom component for rendering AI assistant messages in the chat.
  • Receives response, AIIconComponent, and ResponseChatComponents (used internally to render message, filters, products, and any extra response keys).
  • Render components inside pass index, allData (full response payload), and data (for dynamic keys only) instead of spreading the value as props.
  • Default Value: Built-in AIMessage component with product display support.
const AIMessage = ({ response, AIIconComponent, ResponseChatComponents }: AIMessageProps) => {
	const { message, products = [], filters = [] } = response;
	const {
		message: MessageComp = MessageComponent,
		filters: FiltersComponent = Filters,
		products: ProductsComponent = ProductCarousel,
	} = ResponseChatComponents ?? {};
	return (
		<div className="ai-message-container">
			<div className="ai-message-icon-wrapper">{AIIconComponent && <AIIconComponent />}</div>
			<div className="ai-message-wrapper">
				{message && <MessageComp message={message} />}
				{filters.length > 0 && filters.map((f) => <FiltersComponent key={f.field} field={f.field} options={f.options} onFilterClick={...} />)}
				{products.length > 0 && <ProductsComponent products={products} />}
			</div>
		</div>
	);
};

ResponseChatComponents

optional
object
  • An object of React components used to render parts of the AI response inside AIMessageComponent. Keys map response data to components: message (text), filters (filter chips), products (product list/carousel), and any other keys present in the API response (e.g. custom blocks).
  • Default Value: { message: MessageComponent, filters: Filters, products: ProductCarousel }

Shape:

{
  message?: React.ElementType;   // Renders the assistant text message (receives: message, allData, index)
  filters?: React.ElementType;    // Renders filter options (receives: field, options, onFilterClick, allData, index, data)
  products?: React.ElementType;   // Renders product recommendations (receives: products, allData, index, data)
  table_info?: React.ElementType; // Renders table information (receives: data, allData, index)
  [key: string]: React.ElementType | undefined;  // Extra keys from API response (receives: index, allData, data)
}

message

Component receives message (string). Renders the AI’s text.

I am looking to buy recliners for my living room
user-icon
ai-icon
Great choice! We have a variety of recliners for your living room. Which color do you prefer for your recliner?
// This is a sample code for above example. 
// Please go through the entire documentation for understanding different usecases and update as per your needs.
import { UnbxdShoppingAssistantWrapper } from "@unbxd-ui/react-shopping-assistant-hooks";
import { Chat } from "@unbxd-ui/react-shopping-assistant-components";
 
const MessageComponent = ({ message }: { message: string }) => {
	return (
		<div className="ai-message-container">
			<div className="ai-message-icon-wrapper">
				<img src="/logo.png" alt="ai-icon" />
			</div>
			<div className="ai-message-wrapper">
				<div className="ai-message-text">{message}</div>
			</div>
		</div>
	);
};
 
const ShoppingAssistantApp = () => {
	return <UnbxdShoppingAssistantWrapper>
		...
		<Chat ResponseChatComponents={{ message: MessageComponent }} />
		...
	</UnbxdShoppingAssistantWrapper>
};
 
export default ShoppingAssistantApp;

filters

Component receives field, options, onFilterClick. Renders clickable filter options that call askAgent with the selected filter.

I am looking to buy recliners for my living room
user-icon
ai-icon
Great choice! We have a variety of recliners for your living room. Which color do you prefer for your recliner?
gray
brown
white
black
beige
// This is a sample code for above example. 
// Please go through the entire documentation for understanding different usecases and update as per your needs.
import { UnbxdShoppingAssistantWrapper } from "@unbxd-ui/react-shopping-assistant-hooks";
import { Chat } from "@unbxd-ui/react-shopping-assistant-components";
 
const FiltersComponent = ({ field, options = [] }: { field: string, options: string[] }) => {
	const { askAgent } = useShoppingAssistant();
 
	const handleFilterClick = (option: string) => {
		askAgent(option, { field, options: [option] });
	};
 
	const renderFilters = () => {
		return options.map((option) => (
			<div className="filter-option" key={option} onClick={() => handleFilterClick(option)}>
				{option}
			</div>
		));
	};
 
	return (
		<div className="filters-container">
			{renderFilters()}
		</div>
	);
};
 
const ShoppingAssistantApp = () => {
	return <UnbxdShoppingAssistantWrapper>
		...
		<Chat ResponseChatComponents={{ filters: FiltersComponent }} />
		...
	</UnbxdShoppingAssistantWrapper>
};
 
export default ShoppingAssistantApp;

products

Component receives products (array). Renders a product carousel or list.

I am looking to buy recliners for my living room
user-icon
ai-icon
Great choice! We have a variety of recliners for your living room. Which color do you prefer for your recliner?
1
https://embed.widencdn.net/img/cityfurniture/ox9dbsk98u/640px/S2506980266R00_MI_BENSON_GRY_MC_REC.jpeg?keep=c&crop=no&quality=80&u=m2xgp2

Benson Gray Micro Recliner

2
https://embed.widencdn.net/img/cityfurniture/zjry3lik1y/640px/S2503590002R02_WN_Z_PTIT_LGY_FB_PO_LI_RC.jpeg?keep=c&crop=no&quality=80&u=m2xgp2

Zecliner Petite Light Gray Fabric Power Lift Recliner

3
https://embed.widencdn.net/img/cityfurniture/htwuwpagno/640px/S2506980284R00_MI_RYDER_GRY_MC_REC.jpeg?keep=c&crop=no&quality=80&u=m2xgp2

Ryder Gray Micro Recliner

4
https://embed.widencdn.net/img/cityfurniture/2mh4bsbjdu/640px/S2506980286R00_MI_RYDER_GRY_MC_PO_REC.jpeg?keep=c&crop=no&quality=80&u=m2xgp2

Ryder Gray Micro Power Recliner

5
https://embed.widencdn.net/img/cityfurniture/15knkpuzfh/640px/S2503590004R02_WN_Z_MD_2_LGY_FB_PO_LI_RC.jpeg?keep=c&crop=no&quality=80&u=m2xgp2

Zecliner Model 2 Light Gray Fabric Power Lift Recliner

6
https://embed.widencdn.net/img/cityfurniture/ufjmh9i8jz/640px/S2403310208R00_GY_NOVA_DGY_LR_PO_RE_WM.jpeg?keep=c&crop=no&quality=80&u=m2xgp2

Nova Dark Gray Lthr/vinyl Power Recliner W/ Massage

7
https://embed.widencdn.net/img/cityfurniture/zsssu237rq/640px/S2302342224R00_CE_BENJI_DGY_LV_ZP_RE_HD.jpeg?keep=c&crop=no&quality=80&u=m2xgp2

Benji Dark Gray Lthr/vinyl Zero Gravity Power Recliner W/headrest

8
https://embed.widencdn.net/img/cityfurniture/nfxdatajv9/640px/S2406980204R00_MI_JETT_GRY_MC_PO_REC.jpeg?keep=c&crop=no&quality=80&u=m2xgp2

Jett Gray Micro Power Recliner

9
https://embed.widencdn.net/img/cityfurniture/pocxvuba3k/640px/S2502342325R00_CE_BENNET_GRY_FB_PO_GD_HD.jpeg?keep=c&crop=no&quality=80&u=m2xgp2

Bennett Gray Fabric Power Recliner

10
https://embed.widencdn.net/img/cityfurniture/shijfxdnb1/640px/S1902453168R00_KU_OWEN_DGY_LR_SW_GD_RC.jpeg?keep=c&crop=no&quality=80&u=m2xgp2

Owen Dark Gray Leather Swivel Glider Recliner

// This is a sample code for above example. 
// Please go through the entire documentation for understanding different usecases and update as per your needs.
import { UnbxdShoppingAssistantWrapper } from "@unbxd-ui/react-shopping-assistant-hooks";
import { Chat } from "@unbxd-ui/react-shopping-assistant-components";
import { ProductCard } from "./components/ProductCard";
 
const ProductsComponent = ({ products }: { products: any[] }) => {
	return <div className="products-container">
		{products.map((product) => <ProductCard product={product} />)}
	</div>;
};
 
const ShoppingAssistantApp = () => {
	return <UnbxdShoppingAssistantWrapper>
		...
		<Chat ResponseChatComponents={{ products: ProductsComponent }} />
		...
	</UnbxdShoppingAssistantWrapper>
};
 
export default ShoppingAssistantApp;

table_info

Component receives data (array) that contains the comparison data that can be used to compare products side by side to find the best option for your needs. Use the type="comparison" prop to display the comparison table.

Compare the two top-selling products
user-icon
ai-icon
Here are the two top selling products.
// This is a sample code for above example. 
// Please go through the entire documentation for understanding different usecases and update as per your needs.
import { UnbxdShoppingAssistantWrapper } from "@unbxd-ui/react-shopping-assistant-hooks";
import { Chat } from "@unbxd-ui/react-shopping-assistant-components";
import ProductComparison from "./components/ProductComparison";
 
const TableInfoComponent = (props: any) => {
	const { data = [] } = props;
	const { type } = data[0];
 
	switch (type) {
		case "comparison":
			return <ProductComparison products={data[0]?.data} title={data[0]?.title} />;
		default:
			return null;
	}
};
 
const ShoppingAssistantApp = () => {
	return <UnbxdShoppingAssistantWrapper>
		...
		<Chat ResponseChatComponents={{ table_info: TableInfoComponent }} />
		...
	</UnbxdShoppingAssistantWrapper>
};
 
export default ShoppingAssistantApp;
  • Any other keys on the response object can have a matching component in ResponseChatComponents; they will be rendered with the corresponding value as props.

Related Components