Product Image Search
Product Image Search lets shoppers take or pick a photo in the app's Search screen and get the closest products from your store. The search runs on your own n8n workflow: Cohere turns each product image into a vector, and Supabase finds the images closest to the shopper's photo.
The workflow has two parts:
- Sync (you run it): reads your published products from WooCommerce or Shopify, downloads the main image of each product, creates its embedding with Cohere
embed-v4.0and saves it in the Supabase tableproduct_images. - Search (the app calls it): the app sends the photo to the webhook, the workflow creates its embedding, Supabase returns the closest product images, and the webhook answers with the matching products.
Results are sorted by similarity, so the same product photo comes first (score close to 1.0) and visually similar products follow.
Works on Android, iOS and Web (PWA). It needs the Lifetime, Ultra or Professional plan, or an Extended license.
Requirementsβ
| What | Used for | Where to get it |
|---|---|---|
| n8n (self-hosted recommended, or n8n Cloud) | Runs the sync and the search webhook | n8n.io |
| Supabase project | Stores the product image vectors | supabase.com |
| Cohere API key | Creates image embeddings | dashboard.cohere.com/api-keys |
WooCommerce REST API key (Read), or Shopify Admin API access token (read_products) | Reads your products | WooCommerce: Settings > Advanced > REST API. Shopify: Settings > Apps and sales channels > Develop apps |
You also choose one secret value for the webhook's Header Auth. The same value goes into FluxBuilder as the API Key (step 5).
1. Download and import the workflowβ
In FluxBuilder, go to Features > AI Chat Add-ons.
Next to AI Image Search, click DOWNLOAD WORKFLOW. The file matches the platform of your app.

In n8n, open Workflows > Create > Import from File and pick the downloaded JSON.
2. Set the credentialsβ
Open each node below and select or create its credential.
| Node | Credential | What to enter |
|---|---|---|
| Create Product Images Table and Match Function, Get old products, Match product images | Postgres | Supabase Connect > Session pooler values: host, port 5432, database postgres, user, password |
| Create a row, Delete old products | Supabase API | Host https://<project-ref>.supabase.co and the Service Role Secret (Project Settings > API Keys) |
| Generate Cohere Image Embeddings, Generate Cohere Image Embeddings1 | Cohere API | Your Cohere API key |
| Woo HTTP Request | WooCommerce API | Consumer Key, Consumer Secret and store URL |
| Shopify HTTP Request | Shopify Access Token API | Shop subdomain and Admin API access token |
| Search products by image | Header Auth | Name x-api-key, Value: your secret |
For the Header Auth value, use any long random string, for example from a password generator. Keep it secret.
You only need the credential of your own platform. If n8n will not publish the workflow because the other platform's node has no credential, open that node (Woo HTTP Request or Shopify HTTP Request) and disable it.
3. Create the Supabase tableβ
- Open the node Create Product Images Table and Match Function.
- Click Execute step.
This runs the SQL below once. It creates the product_images table and the match_product_images function used by the search. You can also paste it into Supabase SQL Editor > New query > Run.
create extension if not exists vector with schema extensions;
create table if not exists product_images (
id bigserial primary key,
content text,
metadata jsonb,
embedding vector(1536), -- Cohere embed-v4.0 returns 1536 dimensions
created_at timestamp default now(),
updated_at timestamp default now()
);
create index if not exists product_images_product_id_idx
on product_images ((metadata->>'product_id'));
create or replace function match_product_images (
query_embedding vector(1536),
match_count int default null,
filter jsonb default '{}'
) returns table (
id bigint,
content text,
metadata jsonb,
similarity float
)
language plpgsql
as $$
#variable_conflict use_column
begin
return query
select
id,
content,
metadata,
1 - (product_images.embedding <=> query_embedding) as similarity
from product_images
where metadata @> filter
order by product_images.embedding <=> query_embedding
limit match_count;
end;
$$;
Running it again is safe. It does not delete your data. It also turns on Row Level Security, so the public anon key cannot read or change the table. n8n is not affected: it uses the Postgres credential and the Service Role Secret.
4. Sync your product imagesβ
Open the node Set Parameters and fill in:
Field Value platformwoo,dokan,wcfmorshopifywebsiteUrlYour store URL without a trailing slash, for example https://your-store.comorhttps://your-store.myshopify.comproductPerCallProducts per page, default 25(WooCommerce allows up to100)delaySecondsForEachAPIRequestSeconds to wait between pages, default 3maxExecutionsLeave empty to sync all products. Set 1or2to test with a few pages firstlastCursorLeave empty to start from the first page Click Execute workflow.
Wait until the run ends. The workflow reads one page, indexes it, waits, then reads the next page.
Check the result in Supabase SQL Editor:
select count(distinct metadata->>'product_id') as products_indexed
from product_images;
Good to know:
- Only the main image of each product is indexed. Products without an
https://image are skipped. - Running the sync again is safe. Unchanged products are skipped. Changed products (name, price, description, status or stock) have their old rows deleted and are indexed again.
- Deleted products stay in Supabase. Remove one with
delete from product_images where metadata->>'product_id' = '<id>'; - To keep the index fresh, add a Schedule Trigger (for example daily) and connect it to Set Parameters, next to the manual trigger.
If Cohere returns 429 Too Many Requests (common with a trial key), set productPerCall to 5 and delaySecondsForEachAPIRequest to 60, then run the sync again. Products already indexed are skipped.
5. Activate the webhook and set up FluxBuilderβ
- In n8n, save the workflow and click Publish (or switch it to Active on older n8n versions). The webhook only answers while the workflow is active.
- Open the node Search products by image and copy its Production URL, for example
https://your-n8n.example.com/webhook/v1/search_products_by_image. - In FluxBuilder, go to Features > Branding > Search Product > VIP Settings.
- Under Search by Image, fill in:
- Webhook URL: the Production URL from step 2.
- API Key: your Header Auth value. Leave it empty only if the webhook has no authentication.
- Save the changes.

Use the Production URL (/webhook/...), not the Test URL (/webhook-test/...). The Test URL only works while the n8n editor is listening.
The camera icon appears in the search box of the Search screen when Webhook URL is filled. Leave it empty to turn the feature off.
- Android and iOS: build a new version, or update the config of your current build.
- Web (PWA): build and deploy the web app again.
- Firebase Remote Config: if your app reads its config from Firebase, publish a new Remote Config version with the new
searchConfigvalues. Otherwise the icon stays hidden.
The values are saved in the app config as:
"searchConfig": {
"imageSearchUrl": "<https://your-n8n.example.com/webhook/v1/search_products_by_image>",
"imageSearchApiKey": "your-secret-value"
}
Test the searchβ
Test from the outside in, so each step tells you which part to fix.
Database: run the count query from step 4. It must be more than
0.Webhook with an image URL: use the image URL of one synced product. That product should come first, with
similarityclose to1.0.curl -X POST "<https://your-n8n.example.com/webhook/v1/search_products_by_image>" \
-H "Content-Type: application/json" \
-H "x-api-key: your-secret-value" \
-d '{"image_url":"<https://your-store.com/wp-content/uploads/product.jpg","limit":5,"min_score>":0.3}'Webhook with a photo (what the app sends):
printf '{"data_base64":"%s","limit":10,"min_score":0.3}' "$(base64 < photo.jpg | tr -d '\n')" > body.json
curl -X POST "<https://your-n8n.example.com/webhook/v1/search_products_by_image>" \
-H "Content-Type: application/json" \
-H "x-api-key: your-secret-value" \
-d @body.jsonn8n form (no code): open the trigger On form submission1, open its form URL, upload a photo, then check the run in Executions.
App: open Search, tap the camera icon and take a photo of a product you sell.
| Result | Likely cause |
|---|---|
401 or 403 | The x-api-key header does not match the Header Auth value |
404 | The workflow is not active, or you used the Test URL |
400 with "error": "invalid input" | The request has no data_base64 and no https:// image_url |
200 without products | The index is empty, or min_score is too high |
500 | Open the run in n8n Executions to see which node failed |
Exact match or similar productsβ
The result list is sorted by similarity, so an exact match comes first and similar products follow. The app sends min_score 0.3 and limit 10 with every request.
| Goal | What to change |
|---|---|
| Exact match plus similar products | Nothing, this is the default |
| Exact match only | Open the Filter node and replace its right value with a fixed number, for example 0.8. Adjust it after testing with your own photos |
| More or fewer results | Open the Match product images node and replace the limit in the query with a fixed number |
Webhook APIβ
Use this format if you build your own backend instead of the n8n workflow. The app sends one POST request and waits up to 30 seconds.
Request
POST <https://your-n8n.example.com/webhook/v1/search_products_by_image>
Content-Type: application/json
x-api-key: your-secret-value
{
"data_base64": "<base64 of the compressed JPEG>",
"limit": 10,
"min_score": 0.3
}
| Field | Type | Meaning |
|---|---|---|
data_base64 | string | The photo as base64, with or without the data:image/...;base64, prefix |
image_url | string | Optional, instead of data_base64: a public https:// image URL |
limit | number | Maximum products to return, from 1 to 50. Default 5 |
min_score | number | Minimum similarity to keep. Default 0.5 |
Response
HTTP 200 with a response array. The app reads metadata.product and similarity from each item, sorts by similarity and removes duplicate products.
{
"response": [
{
"id": "128",
"content": "Product: Wireless Earbuds Pro ...",
"similarity": 0.92,
"metadata": {
"product_id": "4521",
"url": "<https://your-store.com/wp-content/uploads/earbuds.jpg>",
"product": {
"id": 4521,
"name": "Wireless Earbuds Pro",
"description": "<p>...</p>",
"type": "simple",
"price": "49.00",
"regularPrice": "59.00",
"inStock": true,
"images": ["<https://your-store.com/wp-content/uploads/earbuds.jpg>"],
"imageFeature": "<https://your-store.com/wp-content/uploads/earbuds.jpg>"
}
}
}
]
}
Any other status code, or a body without a response array, shows no results in the app.
Update from an older workflowβ
If you imported an earlier version of the workflow:
- Download the workflow again (step 1) and import it. Set the credentials again (step 2).
- Run Create Product Images Table and Match Function again (step 3). It keeps your data and turns on Row Level Security.
- Run the sync once (step 4). WooCommerce products are indexed again one time, so their stock status is correct.
- Publish the new workflow and turn off the old one. If the webhook path changed, update Webhook URL in FluxBuilder.
The new version no longer needs the Supabase URL edited by hand in an HTTP Request node. The search uses the Postgres credential.
Troubleshootingβ
| Problem | Fix |
|---|---|
type "extensions.vector" does not exist when creating the table | You are running the old SQL. Use the SQL in step 3 |
permission denied or empty results after the update | The Supabase API credential uses the anon key. Use the Service Role Secret |
| Camera icon missing in the app | Check Webhook URL in step 5, then rebuild or publish a new Firebase Remote Config version |
| Icon shows but no results | Run the tests in Test the search to find the failing part |
| New products are not found | Run the sync again, or add a Schedule Trigger |
| A product is never found by image | Its image URL is broken or empty, so the sync skips it. Fix the image, then run the sync again |
| Products show as out of stock | Run the sync once with the latest workflow |
| Wrong products come first | Use a photo of one product on a plain background. Busy scenes match less well |
| Sync stops on n8n Cloud | Sync in batches with maxExecutions. Products already indexed are skipped on the next run |
Cohere 429 errors | Lower productPerCall and raise delaySecondsForEachAPIRequest |
Cohere is called once per product during the sync and once per search, so the cost grows with your catalog size and search volume.