Vue components
@askdialog/dialog-vue ships ready-made components on top of @askdialog/dialog-sdk. Use it when you want a fast, themed UI in a Vue 3 app without building it from scratch.
Requires Vue 3.
Install
Section titled “Install”npm install @askdialog/dialog-sdk @askdialog/dialog-vueImport the stylesheet once at the entry of your app:
import '@askdialog/dialog-vue/style.css'Initialize the SDK client
Section titled “Initialize the SDK client”Instantiate the SDK once (typically in a top-level component or composable), then pass it to each component.
<script setup lang="ts">import { Dialog, type SimplifiedProduct } from '@askdialog/dialog-sdk'
const client = new Dialog({ apiKey: 'YOUR_PUBLIC_API_KEY', locale: 'en', callbacks: { addToCart: async ({ productId, quantity, variantId }) => { // Hit your cart API, refresh your UI }, getProduct: async (productId, variantId): Promise<SimplifiedProduct> => { // Return your product in SimplifiedProduct shape }, },})</script>See the SDK reference for all constructor options.
DialogProductBlock
Section titled “DialogProductBlock”The headline component. Drop it on a product page to render AI-generated question suggestions and the assistant entry point.
<script setup lang="ts">import { DialogProductBlock } from '@askdialog/dialog-vue'
defineProps<{ product: { id: string; title: string; currentVariantId?: string } }>()</script>
<template> <DialogProductBlock :client="client" :product-id="product.id" :product-title="product.title" :selected-variant-id="product.currentVariantId" /></template>| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
client | Dialog | Yes | — | SDK instance from new Dialog(...). |
productId | string | Yes | — | The current product’s ID. Must match the ID in your catalog. |
productTitle | string | Yes | — | Display name for the product. |
selectedVariantId | string | No | — | The currently selected variant (size, color, etc.). Pass it whenever the user changes variant so the assistant has context. |
enableInput | boolean | No | true | Show the input field under the suggestions. Set to false if you want suggestions only. |
DialogInput
Section titled “DialogInput”A standalone input field for asking a free-form question. Useful as an entry point on pages without a single product context (homepage, blog, collection).
<template> <DialogInput :client="client" product-id="homepage" product-title="Homepage" /></template>| Prop | Type | Required | Description |
|---|---|---|---|
client | Dialog | Yes | SDK instance. |
productId | string | Yes | A stable identifier for the context (e.g. "homepage", "collection-summer"). |
productTitle | string | Yes | A human-readable label for the context. |
Typical layout
Section titled “Typical layout”A common setup:
<DialogInput>on the homepage as a discovery entry point.<DialogProductBlock>on every PDP, between the gallery and the description.- A watcher on the variant selector that updates the
selectedVariantIdprop.
Theming
Section titled “Theming”The components inherit the theme passed to the SDK constructor. Update brand colors, fonts, CTA shape, and component-specific font sizes:
const client = new Dialog({ apiKey: 'YOUR_PUBLIC_API_KEY', locale: 'en', theme: { backgroundColor: '#ffffff', primaryColor: '#000000', ctaTextColor: '#ffffff', ctaBorderType: 'rounded', capitalizeCtas: false, fontFamily: 'Inter, sans-serif', title: { fontSize: '18px', color: '#1a1a1a' }, description: { fontSize: '14px', color: '#666666' }, content: { fontSize: '14px', color: '#333333' }, }, callbacks: { /* ... */ },})Next steps
Section titled “Next steps”- SDK reference — full API for
client. - Tracking — SDK custom — wire side-cart and checkout tracking.
- Add-to-cart issues — keeping your UI in sync.