# n8n Webhook ve Desk360 Public API Kullanım

🧩 Giriş

n8n, görsel tabanlı bir otomasyon aracıdır. Her akış (workflow) tetikleyici (trigger) ve aksiyon (action) adımlarından oluşur.

Bu  adımda, en çok kullanılan iki node olan Webhook ve HTTP Request node'larının nasıl kullanılacağını anlatıyoruz.

🧠 1. Webhook Node Nedir?

Webhook Node, dış sistemlerden (örneğin bir web formu, CRM, veya API) gelen HTTP isteklerini (POST, GET vb.) yakalayarak n8n akışını başlatır.

🔹 Örnek Kullanım Senaryosu

Whatsapp Business API numaranıza mesaj geldiğinde otomatik olarak n8n webhook workflow'unu tetiklemek

⚙ 2. Webhook Node Ayarları

Ayar Açıklama

HTTP Method `GET`, `POST`, `PUT` vb. -- genellikle `POST` kullanılır.

Path Webhook'un URL'sinin son kısmı. Örnek: `/new-message`

Response Mode `On Received` (istek gelir gelmez cevap döner) veya `Last Node`

(workflow tamamlanınca cevap döner).

Response Data İsteğe dönecek JSON veya metin cevabı.

🔹 Örnek Kurulum

Method: POST

Path: /new-message

Response Mode: Last Node

Workflow URL:

`https://n8n.yourdomain.com/webhook/new-message`

Bu durumda, workflow'u tetikler.

`/webhook/new-message` adresine gönderilen tüm HTTP POST istekleri bu workflowu tetikler.

🧩 3. HTTP Request Node Nedir?

HTTP Request Node, n8n içinden başka bir servise veya API' ye istek göndermeni sağlar.

Bu, diğer sistemlerle entegrasyon kurmanın temel yöntemidir.

🔹 Örnek Kullanım Senaryosu

Desk360 Public API'ye mesaj gönderme

⚙ 4. HTTP Request Node Ayarları

Method `GET`, `POST`, `PUT`, `PATCH`, `DELETE` -- isteğin türünü belirtir.

URL API adresi (örnek: `https://public-api.desk360.com/...`)

Authentication Basic Auth, OAuth2, Header Token gibi yetkilendirme seçenekleri

Headers `Content-Type`, `Authorization` vb. özel başlıklar

Body JSON, form-data, URL encoded formatında gönderilecek veri

Response Format JSON, Text, veya Binary

🧾 5. Webhook → AI Message Model → HTTP Request Akışı

Örneği

Bu örnek, Whatsapp Business API numaranıza mesaj geldiğinde Desk360 Public API ayarları

sayfasından ayarlanan webhook url'e POST isteği gönderir. Otomatik olarak n8n webhook

workflow'unu tetikler bu gelen POST isteğini alıp AI modelinde işleyip, AI'dan dönen yanıtı

Desk360 Public API aracılığıyla mesaj gönderen numaraya mesaj gönderir.

NOT: Webhook node kullanabilmek için Desk360 Public API ayarları sayfasından webhook

url'inizi eklemeniz gerekmektedir.

🔹 Adım 1: Webhook Node

Method: POST\\

Path: /`webhook/new-message\`

Response Mode: Last Node

Örnek gelen veri:

```json
{
  "messages": {
    "id": "ABEGkFMIcyRoAgo-sGaD-H6MgPEt",
    "text": "Hello",
    "from": "90xxxxxxxxxx",
    "timestamp": "1630913975",
    "name": "John Doe",
    "type": "text"
  }
}
```

🔹 Adım 2: AI Message Model Node (Opsiyonel)

Model: Gpt-4.1-mini veya başka bir model\\

Input: Sen bir müşteri destek temsilcisi yerine yanıt veren bir chat botsun. Gelen mesaja göre uygun, yalın bir dilde mesaj dönmelisin. \
\
Mesaj: `{{ $json.body.messages.text}}\`

🔹 Adım 3: Desk360 Public API ile Mesaj Gönderme

```
Method: POST
URL: https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages
Headers:
  Authorization: Bearer <API_KEY>
  Content-Type: application/json
Body (JSON):
{
  "to": "+{{ $('Webhook').item.json.body.messages.from }}",
  "text": "{{ $json.message.content.response }}"
}
```

🔹 Adım 3: Webhook Response (Opsiyonel)

Node tipi: Respond to Webhook\\

Response Data:

{% code title="" %}

```
{ "status": "Message sent successfully" }
```

{% endcode %}

🧠 6. Örnek Workflow JSON

Aşağıdaki JSON, yukarıdaki örneğin n8n'e direkt import edilebilen halidir:

```json
{
  "name": "Desk360-PublicApi",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "5012e5b7-e22b-4c0e-927d-",
        "authentication": "headerAuth",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        0,
        0
      ],
      "id": "32724226-6ec0-404f-9a54-",
      "name": "Webhook",
      "webhookId": "5012e5b7-e22b-4c0e-927d-",
      "credentials": {
        "httpHeaderAuth": {
          "id": "scRqgJBSllnf21C8",
          "name": "Header Auth account"
        }
      }
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4.1-mini",
          "mode": "list",
          "cachedResultName": "GPT-4.1-MINI"
        },
        "messages": {
          "values": [
            {
              "content": "=Sen bir müşteri destek temsilcisi yerine yanıt veren bir chat botsun. Gelen mesaja göre uygun, yalın bir dilde mesaj dönmelisin.\nMesaj: {{ $json.body.messages.text }}"
            }
          ]
        },
        "jsonOutput": true,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        208,
        0
      ],
      "id": "787749b6-09d0-42e4-99a0-",
      "name": "Message a model",
      "credentials": {
        "openAiApi": {
          "id": "Dk5hN5YnS94m3tpU",
          "name": "n8n free OpenAI API credits"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://public-api.desk360.com/v1/integrations/:integrationId/conversations/messages",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n \"to\": \"+{{ $('Webhook').item.json.body.messages.from }}\",\n \"text\": \"{{ $json.message.content.response }}\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        560,
        0
      ],
      "id": "ce449f17-ed1b-42ee-80e9-",
      "name": "HTTP Request",
      "credentials": {
        "httpBearerAuth": {
          "id": "vHYqOLNzLykjmQGl",
          "name": "Bearer Auth account"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Message a model",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Message a model": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
```

✅ 7. Sonuç

Bu dokümantasyon sayesinde:

* n8n'de webhook oluşturabilir,
* Gelen verileri alıp işleyebilir,
* HTTP Request node ile Desk360 Public API' ye istek gönderebilirsin.


---

# Agent Instructions: 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:

```
GET https://whatsapp-tr.desk360.com/n8n-webhook-ve-desk360-public-api-kullanim.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
