---
name: tasteray-forme-widget
description: Install and configure the TasteRay ForMe ("Is this for me?") conversational product-page verdict widget on Shopify Liquid, WooCommerce PHP, React/Next.js, Astro, or static HTML storefronts.
---

# TasteRay ForMe Widget Skill

Use this skill when a merchant or developer wants to add an embeddable **"Is this for me?"** conversational match-verdict button to product, media, or catalog detail pages without building a backend proxy.

- **Widget script:** \`https://forme.tasteray.com/widget.js\` (~16 KB gzipped, Shadow DOM isolated, no signup, no API key required)
- **Install guide (Markdown):** \`https://forme.tasteray.com/install.md\` (\`https://forme.tasteray.com/install\`)
- **llms.txt:** \`https://forme.tasteray.com/llms.txt\`
- **AI Catalog:** \`https://forme.tasteray.com/.well-known/ai-catalog.json\`
- **Remote MCP snippet generator (\`generate_forme_widget_snippet\`):** \`https://api.tasteray.com/mcp\` (or stdio \`npx -y github:tasteray/business-mcp\`)
- **Starter examples:** https://github.com/tasteray/business-api-examples
- **Server-side catalog ranking alternative:** **TasteRay Business - Recommendation API** (\`https://api.tasteray.com/SKILL.md\`)

## Step 1: Inspect the repository

Before editing templates, identify the storefront stack and locate two files:

1. **Global layout / script loader:**
   - **Shopify:** \`layout/theme.liquid\`
   - **WooCommerce / WordPress:** child theme \`functions.php\` or custom plugin
   - **React / Next.js:** app layout (\`app/layout.tsx\`, \`pages/_app.tsx\`) or product page component
   - **Astro:** shared layout (\`src/layouts/Layout.astro\`) or product page (\`src/pages/products/[slug].astro\`)
   - **Static HTML:** page template before \`</body>\`
2. **Product or title detail template (PDP):**
   - **Shopify:** \`sections/main-product.liquid\` (or product form block right below the Add to Cart button)
   - **WooCommerce:** \`woocommerce_after_add_to_cart_button\` hook
   - **React / Next.js / Astro / HTML:** product detail component beside or below the primary CTA

## Step 2: Validate required \`data-tasteray-*\` attributes

Never emit an embed missing required attributes — the widget chat endpoint returns HTTP \`400\` if \`data-tasteray-title\` or \`data-tasteray-medium\` is empty or omitted.

| Attribute | Required | Rule & values |
|---|---|---|
| \`data-tasteray-feature\` | **Yes** | Must be exactly \`"for-me"\`. |
| \`data-tasteray-title\` | **Yes** | Non-empty product or title name, properly HTML-escaped. |
| \`data-tasteray-medium\` | **Yes** | Non-empty medium label. Use \`"product"\` for physical e-commerce goods, or \`"book"\`, \`"movie"\`, \`"tv-series"\`, \`"documentary"\`, \`"computer-game"\`, \`"board-game"\`, \`"album"\`, \`"podcast"\`, \`"artist"\`, \`"concert"\`, or any custom non-empty category noun. |
| \`data-tasteray-description\` | Recommended | Plain-text description stripped of HTML tags and escaped (100+ characters produces the sharpest follow-up questions; truncate cleanly around 500 characters). |
| \`data-tasteray-url\` | Recommended | Canonical product or title page URL; enables server-side scrape fallback when description is short or missing. |
| \`data-tasteray-lang\` | Optional | \`"en"\` or \`"pl"\`. Auto-detected from the page if omitted. |
| \`data-tasteray-year\` | Optional | Release or publication year for media titles; omit for physical products. |

## Step 3: Inject script + trigger for the detected stack

### Shopify Liquid

Load the script once before \`</body>\` in \`layout/theme.liquid\`:

\`\`\`liquid
<script src="https://forme.tasteray.com/widget.js" defer></script>
\`\`\`

Place the trigger in \`sections/main-product.liquid\` below the Add to Cart button:

\`\`\`liquid
<div
  data-tasteray-feature="for-me"
  data-tasteray-title="{{ product.title | escape }}"
  data-tasteray-medium="product"
  data-tasteray-description="{{ product.description | strip_html | truncate: 500 | escape }}"
  data-tasteray-url="{{ shop.url }}{{ product.url }}"
  data-tasteray-lang="en"
></div>
\`\`\`

### WooCommerce PHP

Add to the child theme's \`functions.php\` or a dedicated plugin:

\`\`\`php
<?php
add_action('wp_enqueue_scripts', function () {
    if (is_product()) {
        wp_enqueue_script(
            'tasteray-forme-widget',
            'https://forme.tasteray.com/widget.js',
            [],
            null,
            ['strategy' => 'defer', 'in_footer' => true]
        );
    }
});

add_action('woocommerce_after_add_to_cart_button', function () {
    global $product;
    if (!$product instanceof WC_Product) {
        return;
    }
    $description = wp_strip_all_tags($product->get_short_description() ?: $product->get_description());
    printf(
        '<div data-tasteray-feature="for-me" data-tasteray-title="%s" data-tasteray-medium="product" data-tasteray-description="%s" data-tasteray-url="%s" data-tasteray-lang="en"></div>',
        esc_attr($product->get_name()),
        esc_attr(mb_substr($description, 0, 500)),
        esc_url(get_permalink($product->get_id()))
    );
});
\`\`\`

### React / Next.js

\`\`\`tsx
'use client';

import { useEffect } from 'react';

interface TasteRayForMeWidgetProps {
  title: string;
  medium?: string;
  description?: string;
  url?: string;
  lang?: 'en' | 'pl';
  year?: string;
}

export function TasteRayForMeWidget({
  title,
  medium = 'product',
  description,
  url,
  lang = 'en',
  year,
}: TasteRayForMeWidgetProps) {
  useEffect(() => {
    if (document.querySelector('script[src="https://forme.tasteray.com/widget.js"]')) {
      return;
    }
    const script = document.createElement('script');
    script.src = 'https://forme.tasteray.com/widget.js';
    script.defer = true;
    document.head.appendChild(script);
  }, []);

  return (
    <div
      data-tasteray-feature="for-me"
      data-tasteray-title={title}
      data-tasteray-medium={medium}
      data-tasteray-description={description}
      data-tasteray-url={url}
      data-tasteray-lang={lang}
      data-tasteray-year={year}
    />
  );
}
\`\`\`

### Astro

\`\`\`astro
---
interface Props {
  title: string;
  medium?: string;
  description?: string;
  url?: string;
  lang?: 'en' | 'pl';
  year?: string;
}

const { title, medium = 'product', description, url, lang = 'en', year } = Astro.props;
---

<script is:inline src="https://forme.tasteray.com/widget.js" defer></script>
<div
  data-tasteray-feature="for-me"
  data-tasteray-title={title}
  data-tasteray-medium={medium}
  data-tasteray-description={description}
  data-tasteray-url={url}
  data-tasteray-lang={lang}
  data-tasteray-year={year}
></div>
\`\`\`

### Static HTML

\`\`\`html
<script src="https://forme.tasteray.com/widget.js" defer></script>

<button
  data-tasteray-feature="for-me"
  data-tasteray-title="Sony WF-1000XM5 Wireless Earbuds"
  data-tasteray-medium="product"
  data-tasteray-description="Compact noise-cancelling earbuds with 8-hour battery life, multipoint Bluetooth, and foam tips for subway commutes."
  data-tasteray-url="https://example.com/products/sony-wf-1000xm5"
  data-tasteray-lang="en"
>Is this for me?</button>
\`\`\`

## Step 4: Verify before finishing

- [ ] \`https://forme.tasteray.com/widget.js\` is loaded once with \`defer\` (never duplicated per item card).
- [ ] Every trigger carries \`data-tasteray-feature="for-me"\`, a non-empty escaped \`data-tasteray-title\`, and a non-empty \`data-tasteray-medium\`.
- [ ] Descriptions have HTML stripped and quotes escaped, ideally 100+ characters (or \`data-tasteray-url\` is set).
- [ ] No API key is added anywhere (ForMe is free up to 1,000 verdict checks/domain/month; chat endpoint rate limit is 10 req/min/IP; no tracking cookies inside the widget).
- [ ] Clicking the button on a local/staging PDP opens the Shadow DOM modal and starts a ~5-question verdict conversation.
