Chuyển tới nội dung chính

Clan Webhook

Clan webhook will send DM directly to each person's inbox, who receives the message depends on the username or user ID provided on the URL.

Creating a Clan Mezon Webhook

Follow these steps to create a webhook for your clan.

  1. Go to the clan you want to create a webhook for, click on clan banner to bring up a popup of actions that can be performed on that clan.

    mezon-webhook-005

  2. Click on the Clan Settings option and then go to the Integrations tab.

  • As a clan manager you can also manage both channel webhooks and clan webhooks here.

    mezon-webhook-006

  1. Click on Clan Webhooks and then New Clan Webhook to proceed with creating a new webhook.

    mezon-webhook-007

  • You will have one user (here named Komu Knight) and can customize this bot's name and avatar.

  • Click on Copy Webhook URL to get the webhook's endpoint, use it with the webhook payload to send messages to the user in your clan.

  • There are two ways to construct a complete Webhook URL after copying the base URL using the Copy Webhook URL button

    • Way 1: You have to combine the URL you copied with a valid Mezon Username to get a complete Webhook URL. The Mezon Username can be found in the user's Account Settings.

    mezon-webhook-008

    • Way 2: Alternatively, use the copied URL and combine it with a valid Mezon User ID to get a complete Webhook URL. The Mezon User ID can be found in the user's Account popup.

    mezon-webhook-009

Note

If you feel the token on your URL is compromised or outdated, reset it and copy the new URL and make sure the user has joined your clan.

Webhook Specification

Endpoint

The webhook is delivered via an HTTP POST request to a unique URL generated for each webhook integration combined with a unique user identifier.

URL Structure:

https://webhook.mezon.ai/clanwebhooks/{token}/{user-identifier}

URL Parameters:

ParameterTypeDescription
tokenstringA security token for authenticating the request. It appears to be a base64 encoded string or a JSON Web Token (JWT) containing information for verifying the request's authenticity.
user-identifierstringA unique identifier for the Mezon user. It can be either a username or a user ID.

Request Header

HeaderValueDescription
Content-Typeapplication/jsonIndicates that the request body is in JSON format.

Request Body

The body of the request contains a JSON object with the content and attachments of the message to be sent as a direct message to the user.

Root Object

FieldTypeRequiredDescription
contentstringYesA JSON-encoded string containing the message content details
attachmentsarray of objectsNoAn array of attachment objects (images, videos, files, etc.)

Message Content

The content field contains a JSON-encoded string that must be parsed to access the message structure.

Parsed Content Object:

FieldTypeRequiredDescription
tstringYesThe raw text content of the message.
mkarray of objectsNoAn array of objects describing markdown or special formatting.

mk Object (markdown)

FieldTypeRequiredDescription
typestringYesThe type of formatting applied (e.g., "lk" for link, "pre" for preformatted text).
sintegerYesThe starting character index of the formatted segment in the t string.
eintegerYesThe ending character index of the formatted segment in the t string.

Attachments

The attachments array contains objects representing files attached to the message.

Attachment Object

FieldTypeRequiredDescription
urlstringYesThe public CDN URL to access the attachment.
filetypestringYesThe MIME type of the file (e.g., "image/png", "video/mp4").

Clan Webhook example

curl --location --globoff 'https://webhook.mezon.ai/clanwebhooks/{YOUR_TOKEN}/{username_or_userid}' \
--header 'Content-Type: application/json' \
--data '{
"content": "{\"t\":\"Welcome to Mezon Clan webhook!!! [pre] This is a block message. [lk] https://mezon.ai\",\"mk\":[{\"type\":\"pre\",\"s\":33,\"e\":64},{\"type\":\"lk\",\"s\":68,\"e\":85}]}",
"attachments": [
{
"url": "https://cdn.mezon.vn/0/1843962578301095936/1829065039080853500/95_0thumbnail_dog1.jpg",
"filetype": "image/png"
},
{
"url": "https://cdn.mezon.vn/109056000/255856640/4198400/477_0bandicam_2024_11_19_11_10_14_507.mp4",
"filetype": "video/mp4"
}
]
}'

Result

You can see the messages sent from clan webhooks in your Inbox.

mezon-webhook-010

ghi chú

Replace YOUR_TOKEN with your actual webhook token and username_or_userid with either the recipient's Mezon username or user ID. The user must be a member of your clan to receive the direct message.