Getting Started
What is e-bot?
e-botis a chatbot backend that plugs an e-commerce store's social media pages into an AI assistant. When a customer messages your Facebook page (Instagram support is on the way), e-bot answers product, pricing, policy, and delivery questions automatically — and can take an order end-to-end inside Messenger.
It runs on FastAPI, PostgreSQL with pgvector, Redis, Celery, and OpenAI's tool-use API. Visual search is powered by DINOv2 — when a customer sends a product photo, the bot finds the matching item by image similarity, not by keyword guesswork.
How it works
Every customer message follows the same five-step pipeline:
- 10
Message arrives
A customer sends text, an image, or both to your Facebook page. Facebook forwards the event to e-bot's webhook.
- 21
Background queue
The webhook hands the event to a Celery worker so the request returns instantly — no Facebook timeouts.
- 32
Search or reason
If the customer sent an image, DINOv2 finds the matching product via pgvector similarity search. If it's text, the LLM decides which tool to call (search_products, list_products, get_delivery_zones, place_order, …).
- 43
Compose the reply
The LLM receives the tool result plus the conversation history and writes a reply in the customer's own language.
- 54
Send back
e-bot sends the reply through the Messenger Send API. The whole loop usually takes under three seconds.
Set up your store
Onboarding takes about 15 minutes if your product catalog is ready. Each step below corresponds to a screen in the e-bot dashboard.
Create a store account
From the dashboard, click ‘New Store’ and give your store a name. You'll get a store ID — most API endpoints are scoped to it.
Connect your Facebook Page
You'll need a Page Access Token from Meta Business Suite. Paste it into the Connections screen along with your Page ID. The token is encrypted before being stored.
Upload your product catalog
Add products one at a time or upload up to 100 at once via Bulk Import. Each product needs a title, price, stock count, sizes, and at least one publicly-accessible image URL. Optional fields: description, discount, offer text. After upload, DINOv2 generates a visual embedding in the background.
Add delivery zones
Tell the bot what areas you deliver to and what each one costs (e.g. Inside Dhaka — 60 BDT, Outside Dhaka — 120 BDT). The bot uses these zones during the Messenger order flow.
Add physical store locations
If you have brick-and-mortar branches, add their address, phone, and opening hours. Customers asking ‘where is your shop?’ get an accurate answer.
Write a return / exchange policy
Plain text in the store settings. The bot quotes it back verbatim when customers ask about returns.
Go live
Subscribe your Page to the webhook (the dashboard generates the URL and verify token). Send a test message to confirm the round-trip works, then let real customers in.
What customers can do
- Image search — send a photo, get the matching product with price, sizes, and stock.
- Text search— ask “black winter t-shirt er price koto?” and get a hit from the catalog.
- Browse — ask to see all products or filter by size or price range.
- Store info — opening hours, branch locations, return policy.
- Delivery — ask about zones and charges before ordering.
- Place an order — a four-step conversational flow inside Messenger: confirm intent → address → delivery zone → final confirmation.
- Follow-up— “XL ache?” or “return kora jabe?” after a product is identified are answered from a 5-minute Redis cache, no repeat database hit.
Languages
e-bot detects whether the customer wrote in English, Bangla (বাংলা), or Banglish(Bengali meaning written in English letters — “ei ta koto?”).
Replies are always in the customer's language. The bot never switches unless the customer does. This is enforced in the system prompt — you don't need to configure anything.
FAQ
How much does the OpenAI API cost per conversation?
Every LLM call is logged per store in the token_usage table. You can monitor cumulative cost from the dashboard. A typical product question uses 1–3 tool calls, around 1,500–3,000 tokens total. Image-search-only flows skip the LLM entirely.
What happens if my Facebook Page Access Token expires?
Messenger calls will start failing with a 401. The bot will keep accepting webhooks but won't be able to reply. Reconnect the page from the Connections screen to refresh the token.
Can I edit a product after it's uploaded?
Yes — from the Products screen. If you change the images, the visual embedding is regenerated in the background.
How many products can I have?
There is no hard cap. pgvector with the HNSW index keeps similarity search fast into the tens of thousands of items.
Does the bot place orders without confirmation?
No. The order flow always shows the customer a full summary (items, subtotal, delivery charge, total) and waits for an explicit confirmation before calling place_order.
Can the bot message a customer first?
Yes, via the proactive messaging endpoint. Outside Facebook's 24-hour window you must include a valid message_tag (POST_PURCHASE_UPDATE, CONFIRMED_EVENT_UPDATE, or HUMAN_AGENT).
Where is data stored?
Products, orders, and conversations are in PostgreSQL. Redis holds the 5-minute product context cache and Celery task queue. Facebook access tokens are encrypted at rest.
Does Instagram work?
Not yet — it's on the roadmap. Today only Facebook Messenger is supported.
API Reference
Overview
The HTTP API is a thin layer over the same database the bot reads. Everything is JSON. Authentication is environment-specific — in self-hosted deployments the API is reached on a private network or behind your own auth gateway.
Base URL
http://localhost:8000/api/v1Response envelope
Every endpoint returns this shape:
{
"success": true,
"data": { /* endpoint-specific payload */ },
"error": null
}On failure, success is false, data is null, and error contains a message string.
Stores
Create a store
/stores{
"name": "My Fashion Store",
"owner_id": "user_123"
}{
"data": {
"id": 1,
"name": "My Fashion Store",
"owner_id": "user_123",
"description": null,
"return_policy": null,
"created_at": "2026-04-06T10:00:00Z",
"updated_at": null
}
}Get a store
/stores/{store_id}Update a store
/stores/{store_id}All fields are optional.
{
"name": "Updated Store Name",
"description": "We sell premium fashion for all seasons.",
"return_policy": "Returns accepted within 7 days with original tag."
}Facebook Pages
Connect a page
/stores/{store_id}/connect-page{
"page_id": "123456789",
"page_name": "My Fashion Store",
"page_access_token": "EAAxxxxxx..."
}The page_access_token comes from the Facebook Graph API. The token is encrypted before persisting.
List connected pages
/stores/{store_id}/pagesDelivery Zones
Add a zone
/stores/{store_id}/delivery-zones{
"zone_name": "Inside Dhaka",
"charge": 60.00,
"description": "All areas within Dhaka city"
}List, update, delete
/stores/{store_id}/delivery-zones/stores/{store_id}/delivery-zones/{zone_id}/stores/{store_id}/delivery-zones/{zone_id}Store Locations
Add a location
/stores/{store_id}/locations{
"location_name": "Dhanmondi Branch",
"address": "House 10, Road 4, Dhanmondi, Dhaka",
"phone": "01700000000",
"opening_hours": "Sat-Thu: 10am-9pm"
}List, update, delete
/stores/{store_id}/locations/stores/{store_id}/locations/{location_id}/stores/{store_id}/locations/{location_id}Products
Add one product
/products{
"title": "Black Winter T-Shirt",
"descriptions": "Premium quality cotton winter t-shirt.",
"price": 850.00,
"currency": "BDT",
"stock": 50,
"sizes": ["S", "M", "L", "XL"],
"images": [
"https://cdn.example.com/black-tshirt-front.jpg",
"https://cdn.example.com/black-tshirt-back.jpg"
],
"discount": 10.00,
"offer": "10% off this week",
"store_id": 1
}After creation, visual embedding generation runs in the background. Image URLs must be publicly accessible.
Bulk import (max 100 per call)
/products/bulk{
"products": [
{
"title": "Red Hoodie",
"price": 1200.00,
"currency": "BDT",
"stock": 30,
"sizes": ["M", "L", "XL"],
"images": ["https://cdn.example.com/red-hoodie.jpg"],
"store_id": 1
}
]
}Get a product
/products/{product_id}Orders
List orders
/stores/{store_id}/ordersFilter with ?status= where status is one of pending, confirmed, cancelled, delivered.
{
"data": [
{
"id": 1,
"store_id": 1,
"messenger_user_id": 5,
"conversation_id": 2,
"delivery_address": "House 10, Road 4, Dhanmondi",
"delivery_zone_name": "Inside Dhaka",
"delivery_charge": "60.00",
"subtotal": "850.00",
"total": "910.00",
"currency": "BDT",
"status": "pending",
"created_at": "2026-04-06T10:00:00Z",
"items": [
{
"id": 1,
"product_id": 42,
"product_name": "Black Winter T-Shirt",
"size": "L",
"quantity": 1,
"unit_price": "850.00",
"currency": "BDT",
"line_total": "850.00"
}
]
}
]
}Get one order
/stores/{store_id}/orders/{order_id}Proactive Messaging
Send a message to a customer outside of an in-progress conversation — e.g. an order confirmation or a delivery update.
/stores/{store_id}/send-message{
"page_id": "123456789",
"recipient_id": "PSID_of_the_customer",
"message": "Your order has been confirmed! We'll deliver within 2-3 days.",
"message_tag": "POST_PURCHASE_UPDATE"
}message_tag is required if the customer last interacted more than 24 hours ago. Valid values: POST_PURCHASE_UPDATE, CONFIRMED_EVENT_UPDATE, HUMAN_AGENT. Omit it if the customer messaged within the last 24 hours.
Webhook
Facebook calls these endpoints — you generally don't hit them directly. The verification endpoint is used once during Page subscription; the POST endpoint receives every Messenger event going forward.
/webhook/webhookHealth
/healthReturns 200 with { "status": "ok" } when the API is reachable. Use this as your container health probe.