# 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="/files/3Z67Tz2XJli4xbuPjdCf" 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="/files/1br4v07U27WyH2MJCC6U" 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>


---

# 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://docs.klink.cloud/getting-started/setup-channels/custom-channel.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.
