# Chat

The shop has its own chat: a **Scrie-ne** button on every storefront page, answered from **Admin → Chat**. No outside
chat service is involved and no visitor data leaves the shop.

## Switching it on and the hours

**Setări → Chat** (*Sets up chat*): switch the chat on, set the hours for each day of the week (leave a day empty when
nobody answers), keep the Romanian public holidays closed (the year's dates are listed), and add days with other hours,
one per line: `2026-12-24 10:00-14:00` or `2026-12-31 închis`. You also set the greeting, how many minutes an answer
takes (the widget says it), and how many months conversations are kept.

## How a conversation goes

- **Someone online, within the hours**: the visitor writes, a person answers in the inbox, and the visitor sees the
  answer in the widget. A person counts as online while **Eu sunt: Online** is chosen and the inbox page is open.
- **Out of hours, or nobody online**: the visitor leaves a message and an e-mail address, gets an automatic reply
  saying when you are back (marked as automatic), and the conversation goes to **Pe e-mail**. Your answer to it leaves
  by e-mail.

## The inbox

**Admin → Chat** (*Answers in chat*) has the folders **Deschise**, **Pe e-mail**, **Ale mele** and **Închise**. Beside
a conversation you see the customer (for a signed-in customer, their latest orders) and the page they wrote from.
Assign a conversation to a colleague, write an **internal note** (the customer never sees it), or close it. Automatic
messages and notes are labelled in words in the transcript.

## „Unde e comanda mea?”

The widget has a **Unde e comanda mea?** button. A signed-in customer gets the status of their latest order (or the one
whose number they type); anyone else types the order number and the e-mail or phone on the order. The answer comes from
the order itself, without AI: its status, and the courier, AWB and tracking link once it has shipped. Inside a
conversation the question and the answer join the transcript, the answer marked as automatic. Wrong details get the
same short answer whatever was wrong, and only a few tries are allowed (a minute per visitor, and a day per order number and per e-mail or phone), so order
numbers cannot be guessed.

## The shopping assistant (AI)

An AI assistant can answer in the chat. It needs two switches:

1. **Asistentul de cumpărături** (shopping assistant) under Settings → AI, with a model and a daily budget. Shoppers
   set it off, so it cannot be switched on without a budget.
2. **When it answers** under Settings → Chat:
   - **Primul, în orice conversație**: first, in every conversation;
   - **Doar în afara programului**: out of hours only.

What it does:

- **It says it is an AI**, in its first message (EU AI Act, Article 50). Its messages are marked *Asistent virtual (AI)*
  in the widget and *Asistent AI* in the inbox.
- **It answers only from what the shop finds:**
  - products, through the shop's search;
  - the signed-in customer's own orders, through the order-status bot (guests are pointed to the order button);
  - the delivery, returns, terms and privacy pages;
  - the stores and their hours today.
- **It never states a price, an amount or stock.** The products it names show under its message as cards with the price
  and availability the shop has at that moment. An answer that quotes a price anyway is replaced by a plain line.
- **It hands over to a person**, with a note in the inbox saying why and summing up the conversation:
  - when the shopper asks for one ("operator", "om", "persoană");
  - always for refunds and complaints, which the shop recognises from the shopper's words before the model sees them;
  - when the model is unsure, or not available (off, out of budget, not answering);
  - after 30 answers.

  Within working hours the shopper is told a colleague is coming. Out of hours, they're told a colleague answers when
  the shop opens, here and by e-mail.
- **A colleague writing in the conversation takes it over;** the assistant stops there.
- Only the last messages are sent, after e-mail addresses and long digit runs (phones, CNP, IBAN) are taken out.

## Saved replies

**Răspunsuri salvate** (from the inbox, *Sets up chat*) keeps texts you use often. In a conversation, choose one above
the reply box and it fills in: `{nume}` with the customer's first name, `{comanda}` with their latest order and
`{link_urmarire}` with its parcel's tracking link. What is not known stays empty, so read it before sending.

## Proactive messages

**Chat → Mesaje proactive** (proactive messages, *Manages chat*) is where you choose when the chat offers help
before anyone asks: a small card above the chat button, marked *mesaj automat*, with **Răspunde** (reply) and a close
button. Each message has:

- **Când apare** (when it shows): the basket passes a value (VAT included); a card payment just failed (on the order
  page); a returning customer (signed in, with earlier orders); or on some pages;
- **Doar pe paginile care încep cu** (only on pages starting with), e.g. `/produs/` or `/finalizare`; required for
  "on some pages";
- **După** (after): how many seconds the page is open before it shows;
- the text, in each language of the shop;
- **Doar când e cineva de serviciu** (only while someone is on duty), on by default: no offer of help when nobody
  answers.

A visitor sees at most one proactive message a visit, never while they have a conversation open and never on top of
the cookie question. Messages are tried in the order you added them; the first that fits shows. When the visitor
answers, the message opens the conversation, so you see what they answered. Each message counts how often it was
shown and answered.

## WhatsApp and Messenger

Messages customers send to the shop's **WhatsApp Business** number or **Facebook Page** land in the same inbox,
marked *WhatsApp* or *Messenger* with the customer's number or id; your replies go back on that channel, and an
out-of-hours conversation gets the same automatic reply there. Each reply shows *Trimis pe WhatsApp* once the channel
took it, or *Netrimis* with the reason.

Setting it up, once, in [Meta for Developers](https://developers.facebook.com) with a Meta business account:

1. Create an app, add **WhatsApp** (or **Messenger**) to it, and connect the shop's number (or Page).
2. In SyncSHOP, **Setări → Integrări → WhatsApp Business** (or Facebook Messenger): type the number's id (or the Page
   id), a permanent access token, the app secret, and a verify token you make up; switch it on and save.
3. In Meta, set the webhook: the address shown on that SyncSHOP page (`…/webhooks/messaging/whatsapp`) and the same
   verify token, then subscribe to **messages** (Messenger: **messages**, not echoes). Meta checks the address at
   once; SyncSHOP answers only with your token, and checks Meta's signature on every message.

**The reply window.** WhatsApp lets a business reply freely only within 24 hours of the customer's last message;
later it takes only templates Meta approved, which SyncSHOP does not send. Messenger allows 24 hours too, or 7 days
when Meta has approved the *Human Agent* tag for your app (a switch on the Messenger integration). The inbox says
when the window is closing or closed, and a reply that cannot go out is refused with the reason. The customer only has
to write again.

Photos, voice notes and other content customers send show as a note in the transcript; answer those in the app if
needed. The shopping assistant does not answer on these channels; your team does. Meta is a processor of these
conversations: name it in your privacy policy if you switch a channel on. Transcripts follow the same retention as
the website chat.

## Photos and files

Once a conversation has started, the visitor can attach a photo (JPG, PNG, WebP) or a PDF of up to 5 MB, for example
a damaged parcel. Files are checked by what they contain, kept privately, and open for staff only as a download from
the conversation.

## Unanswered conversations

When a customer has waited more than three times the reply time you promise (at least 15 minutes), those who manage
the chat get an e-mail with links to the waiting conversations, once per conversation. The task runs every 10 minutes
under **Setări → Sarcini programate**.

## Privacy

Conversations belong to the customer's record: they are in the data a customer downloads from their account and are
deleted with the account (including those started as a guest with the same e-mail, once the account's e-mail is confirmed); internal notes
are not part of what the customer downloads. Conversations quiet for longer
than the months set under **Setări → Chat** are deleted on their own, files and all.

The widget works by keyboard and screen reader, speaks the page's language, accepts plain text only, and is
rate-limited against spam.
