> For the complete documentation index, see [llms.txt](https://developer.konukcrm.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.konukcrm.com/entegrasyonlar/web-chat-widget.md).

# Web Chat Widget

Sitenize gömülen widget, ziyaretçi mesajlarını doğrudan ajanların mesajlaşma gelen kutusuna düşürür. Ziyaretçi tarafı anonimdir — token gerekmez.

## Kurulum

1. {{Ayarlar → Entegrasyonlar → Web Chat Widget}} üzerinden widget oluşturun.
2. Verilen **widget anahtarını** kopyalayın.
3. Snippet'i sitenizin `</body>` etiketinden hemen önce ekleyin.

```html
<script
  src="https://{{cdn.konukcrm.com}}/widget.js"
  data-widget-key="{{wgt_xxxxxxxx}}"
  defer
></script>
```

Script `defer` ile yüklenir ve sayfanın render'ını engellemez.

## Yapılandırma

Görünüm ve metinler panelden yönetilir; kod tarafında geçersiz kılabilirsiniz:

```html
<script>
  window.KonukCRMChat = {
    key: "{{wgt_xxxxxxxx}}",
    locale: "tr",
    position: "bottom-right",   // bottom-right | bottom-left
    theme: {
      brand: "#14706b",
      accent: "#8fe0b6"
    },
    greeting: "{{Merhaba! Rezervasyon için size nasıl yardımcı olabiliriz?}}"
  };
</script>
```

## JavaScript API

Widget yüklendiğinde `window.KonukCRMChat` üzerinde metotlar açılır:

| Metot                               | Açıklama                                                |
| ----------------------------------- | ------------------------------------------------------- |
| `.open()`                           | Sohbet penceresini açar                                 |
| `.close()`                          | Kapatır                                                 |
| `.identify({ name, email, phone })` | Ziyaretçiyi tanıtır; ajan panelinde görünür             |
| `.setContext({ ... })`              | Serbest anahtar/değer bağlam (örneğin görüntülenen oda) |
| `.on("message", cb)`                | Gelen mesaj olayını dinler                              |

```javascript
// Kendi "Bize ulaşın" düğmenizden widget'ı açın
document.querySelector("#iletisim").addEventListener("click", () => {
  window.KonukCRMChat.open();
});

// Giriş yapmış ziyaretçiyi tanıtın
window.KonukCRMChat.identify({
  name: "{{Ada Yılmaz}}",
  email: "{{ada@example.com}}"
});
```

## Origin izin listesi

Widget yalnızca panelde tanımladığınız alan adlarından çalışır. İzin verilmeyen bir origin'den yüklenirse istek reddedilir. Geliştirme için `localhost` girişini ayrıca ekleyin.

## Güvenlik notları

* Widget anahtarı **gizli değildir** — istemci tarafında görünür. Yetki taşımaz, yalnızca hangi tenant'a mesaj düşeceğini belirler.
* Kötüye kullanımı önlemek için origin izin listesi ve hız limiti uygulanır.
* Ziyaretçiden alınan hiçbir veri, ajan onaylamadan CRM misafir kaydına yazılmaz.

## İçerik Güvenlik Politikası (CSP)

Sitenizde CSP varsa şu kaynaklara izin verin:

```
script-src  https://{{cdn.konukcrm.com}};
connect-src https://{{api.konukcrm.com}} wss://{{api.konukcrm.com}};
img-src     https://{{cdn.konukcrm.com}} data:;
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developer.konukcrm.com/entegrasyonlar/web-chat-widget.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
