This topic describes how to obtain webhook URLs for DingTalk, Lark, Slack, and Telegram bots and configure a custom URL in OceanBase Cloud.
DingTalk bot
Note
For more information, see Get the webhook URL of a custom bot.
Log in to the DingTalk client and enter the target DingTalk group.
Click the Group settings icon in the upper-right corner, and then choose Bots > Add Bot in the Group Management section.
In the dialog box that appears, select Custom bot.
On the bot details page, click Add.
On the page that appears, specify the parameters.
ParameterDescriptionBot Profile Photo The profile photo of the bot displayed in the group. Bot Name The name of the bot displayed in the group. Security Settings For OceanBase Cloud alerts, select Custom keywords. Note
We recommend that you add
OceanBaseandOBas keywords to receive OceanBase Cloud alerts.Select Custom Bot Service and Disclaimer, and then click Complete.
Click the Group settings icon, choose Group Management > Bots, select the custom bot, and copy its webhook URL.
Note
We recommend that you keep the webhook URL confidential and do not disclose it to public websites such as GitLab and blogs. Otherwise, you may receive malicious spam messages.
Lark bot
Note
For more information, see Custom bot usage guide.
Log in to the Lark client and enter the target chat group.
In the upper-right corner of the group chat window, choose More > Settings. In the settings pane, choose Bots > Add Bot.
In the dialog box that appears, click Custom bot.
Specify the avatar, name, and description of the custom bot, and click Add.
Copy the webhook URL, and click Finish.
Note
We recommend that you keep the Webhook URL confidential and do not disclose it to public websites such as GitLab and blogs. Otherwise, you may receive malicious spam messages.
Optional: Open the custom bot details page and configure security settings.
ParameterDescriptionWebhook URL You can copy the webhook URL of the bot. Security settings For OceanBase Cloud alerts, select Set Keywords. Note
We recommend that you enter
OceanBaseandOBas keywords and then click Save.Settings Set the bot management permissions.
Telegram bot
Create a Telegram alert bot.
In the Telegram search bar, search for @BotFather and open a chat with it.
Enter
/newbotto create a new bot, then follow the prompts to enter the bot's display name and username.Save the bot's username and the API token returned by BotFather after the bot is created.
Note
Keep the API token confidential. Anyone who has the token has full control of the bot.
Obtain the chat ID.
Create a group chat, and add the bot to the group by using its username.
In the group chat, send a command that the bot can receive, such as
/start@<bot_username>, replacing<bot_username>with the bot's username.The Telegram client does not display the group chat ID. Query it by using the Bot API in a browser.
Enter the following URL in the address bar to retrieve the latest updates received by the bot:
Use this URL format:
https://api.telegram.org/bot<token>/getUpdates, replacing<token>with the API token obtained when creating the bot.Example URL:
https://api.telegram.org/bot123456:ABC-DEF1234ghIkl-zyx57W2v1********/getUpdates.Note
The
getUpdatesmethod does not work while an outgoing Telegram webhook is configured for the bot.In the JSON response, find
result[].message.chat.id. Its value is the group chat ID.Note
If the group chat undergoes changes, such as being upgraded to a supergroup, the chat ID may change. Ensure you retrieve the latest chat ID when needed.
Construct the webhook URL.
Use the following URL format, replacing
<token>with the bot's API token and<chat_id>with the group chat ID. OceanBase Cloud automatically supplies the alert message content when it calls the Telegram Bot API.https://api.telegram.org/bot<token>/sendMessage?chat_id=<chat_id>Example:
https://api.telegram.org/bot123456:ABC-DEF1234ghIkl-zyx57W2v1********/sendMessage?chat_id=-45********Configure the Telegram webhook in OceanBase Cloud.
- When you create or edit an alert contact, select Telegram in the Webhook section.
- Enter the webhook URL constructed in the previous step, and click Test.
- After the test succeeds, select the notification language and save the alert contact.
Slack bot
To obtain and configure the webhook URL of a Slack bot, perform the following steps:
Note
For more information about Slack incoming webhooks, see Sending messages using incoming webhooks.
Go to the Slack app management page, and click Create New App.
Select From scratch, specify an app name, select the target workspace, and click Create.
In the left-side navigation pane, click Incoming Webhooks, and turn on Activate Incoming Webhooks.
Click Add New Webhook to Workspace.
Select the channel to which you want to send alert notifications, and click Authorize. To use a private channel, make sure that you are already a member of the channel.
In the Webhook URLs for Your Workspace section, copy the webhook URL.
Note
Keep the webhook URL confidential. Do not disclose it on publicly accessible websites or in public code repositories.
When you create or edit an alert contact in OceanBase Cloud, select Slack in the Webhook section, enter the webhook URL, and click Test.
After the test succeeds, select the notification language and save the alert contact.
Custom URL
To configure a custom webhook URL, perform the following steps when you create or edit an alert contact:
In the Webhook section, select Custom URL.
Enter the webhook URL and configure the following parameters as needed.
ParameterConfigurationHTTP Header Enter HTTP header names and values. You can add multiple headers. Examples: API-Key: ******andContent-Type: application/json;charset=UTF-8.Request Method Select POST or PUT. Success Response Validation Rule Specify how OceanBase Cloud determines whether the HTTP request succeeds. Do not use dynamic fields such as IDs, timestamps, trace IDs, or sequence numbers. For a JSON response, specify a fixed key-value pair, such as {"code":"SUCCESS"}. Validation succeeds if the response contains the specified key-value pair. For a non-JSON response, specify a regular expression. Validation succeeds if the response content matches the regular expression.Click Test. After the test succeeds, select the notification language and save the alert contact.
Note
A custom webhook URL may be blocked by the firewall. If this occurs, contact OceanBase Technical Support for assistance.
