# Custom Channel

The **Custom Channel** allows you to connect **any third-party messaging platform** to **klink.cloud** using webhooks.

Once connected, messages from your system will appear in the **klink.cloud Unified Inbox**, and agent replies can be sent back to your platform automatically.

***

### Where to Find Custom Channel

1. Go to **Settings**
2. Click **Message Integration**
3. Select **Custom Channel**
4. Click **Create / Setup Custom Channel**

***

### How Custom Channel Works

Custom Channel uses **two webhooks**:

* **Outbound Webhook**\
  klink.cloud → sends messages & events to your server
* **Inbound Webhook**\
  Your server → sends messages into klink.cloud

Both are required for two-way messaging.

***

### Step 1: Set Up Outbound Webhook

*(klink.cloud → Your System)*

This step allows klink.cloud to send messages and events to your server.

<figure><img src="https://420146782-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqqwHJh6YA4uvzfFRLnoR%2Fuploads%2FmDJ1gHuHAXdEjKbYo4TZ%2Fimage.png?alt=media&#x26;token=13aef4cf-15c4-4ae6-9b44-3bae54e53f63" alt=""><figcaption></figcaption></figure>

#### Steps

1. In **Outbound Webhook**, enter your server URL:

   ```
   https://your-webhook-server.com/webhook
   ```
2. (Optional) Add headers if your server requires authentication:

   ```
   Authorization: Bearer YOUR_API_KEY
   ```
3. Click **Next**

#### What This Does

* Agent replies
* Incoming messages
* Conversation events

will be sent to your server in real time.

***

### Step 2: Set Up Inbound Webhook

*(Your System → klink.cloud)*

This step allows your system to send messages **into** klink.cloud.

<figure><img src="https://420146782-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqqwHJh6YA4uvzfFRLnoR%2Fuploads%2FnGCl33xSUQZpPExOhxyI%2Fimage.png?alt=media&#x26;token=8c01a595-2ca5-4d51-8d86-aaa8cc16689d" alt=""><figcaption></figcaption></figure>

#### Steps

1. Copy the **Inbound Webhook URL** shown on screen\
   Example:

   ```
   https://me.klink.cloud/custom-channel/xxx/xxx/webhook
   ```
2. Use this URL in your backend or application to send messages to klink.cloud
3. Click **Complete Setup**

> 🔒 Keep this URL private. Anyone with this URL can send messages to your inbox.

***

### Sending Messages to klink.cloud (Inbound Webhook)

#### Endpoint

```
POST {Inbound Webhook URL}
```

#### Headers

```
Content-Type: application/json
```

#### Example Request

```json
{
  "messageId": "msg-001",
  "content": "Hello from our custom platform",
  "sender": {
    "id": "user-123",
    "name": "John Doe"
  },
  "timestamp": 1765440758023,
  "type": "text"
}
```

#### What Happens

* A **new conversation** is created in klink.cloud
* Message appears instantly in the Unified Inbox

***

### Continue an Existing Conversation

To reply to an existing conversation, include `conversationId`:

```json
{
  "messageId": "msg-002",
  "content": "Following up on the issue",
  "sender": {
    "id": "user-123",
    "name": "John Doe"
  },
  "timestamp": 1765440850000,
  "type": "text",
  "conversationId": "ca7de328-32da-4468-bae0-872e94f56be0"
}
```

***

### Receiving Messages from klink.cloud (Outbound Webhook)

klink.cloud sends POST requests to your **Outbound Webhook URL** when:

* Customers send messages
* Agents reply
* Conversations are created or closed

#### Example Payload

```json
{
  "event": "message.sent",
  "conversationId": "ca7de328-32da-4468-bae0-872e94f56be0",
  "message": {
    "content": "How can I help you?",
    "sender": {
      "role": "agent",
      "name": "Support Agent"
    },
    "timestamp": 1765440789000
  }
}
```

***

### Common Events You’ll Receive

| Event                  | Description              |
| ---------------------- | ------------------------ |
| `message.received`     | Customer sent a message  |
| `message.sent`         | Agent replied            |
| `conversation.created` | New conversation started |
| `conversation.closed`  | Conversation closed      |

***

### Testing the Integration

* Use the **Sample Test Message** provided in the UI
* Send it via Postman, cURL, or your backend
* Confirm the message appears in the inbox

***

### Security Best Practices

* Always use **HTTPS**
* Use headers for authentication
* Do not expose inbound webhook URL publicly
* Validate all incoming requests

***

### Supported Message Types

| Type   | Status         |
| ------ | -------------- |
| Text   | ✅ Supported    |
| Images | 🔜 Coming soon |
| Files  | 🔜 Coming soon |

***

### Typical Use Cases

* Custom chat applications
* Internal company messengers
* AI bots & agents
* CRM or ERP messaging
* Legacy system integrations

***

### Need Help?

* 📘 Documentation: <https://docs.klink.cloud>
* 💬 Support: <support@klink.cloud>
