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.
Open DingTalk on your desktop, and open the target group chat that you want to send the alert notifications to.
Click the Group settings icon in the upper-right corner, and then choose Bots > Add Bot in the Group Management section.
Select Custom bot.
Complete the settings for the bot. For Security Settings, select Custom keywords and enter
OB,OceanBase,OBCloud, andtestto receive notifications from OceanBase Cloud.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 for the alert contact configuration.
Notice
Please keep your webhook URL in a secure place. Do not disclose it on websites that can be publicly accessed to avoid malicious invocation of the URL.
Lark bot
Note
For more information, see Custom bot usage guide.
Open Lark on your desktop, and open the target group chat that you want to send the alert notifications to.
Select More > Settings in the upper-right corner, and then click Bots.
Click Add Bot, and then select Custom bot.
Specify the bot's avatar, name, and description, and click Add.
Copy the bot's webhook URL for the alert contact configuration, and click Finish.
Notice
Please keep your webhook URL in a secure place. Do not disclose it on websites that can be publicly accessed to avoid malicious invocation of the URL.
Optional: Open the custom bot details page. For Security settings, select Set Keywords, enter
OBandOceanBase, and click Save.
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.
