Configure the Bot as an Incoming Webhook Notifier
Next, let’s configure the bot as an incoming webhook notifier, that performs actions when the webhook URL is invoked on GitHub. You can do this in the following way:
- Generate a webhook token on the Cliq bot
- Obtain the App key of your extension
- Obtain the webhook handler URL of your extension
- Create a webhook on GitHub and configure these values
We will discuss these actions in detail one after the other.
This webhook gets triggered whenever a commit is pushed to one of the repositories on your Git account. When that event occurs, GitHub makes an HTTP request to the URL webhook handler URL with the credentials that we configure. It will pass the details of that push event to Cliq, and the Cliq bot will notify you of it and display the details.
Generate a WebHook Token
You can generate a webhook token on Cliq as described below. The webhook token is authenticated by the authenticate button function that we configured in the previous step.
- Search for the GitHub bot in your Cliq account. Select the bot and click Continue.
- Provide permission for the bot to access your account details.
The chat will be activated.
- Type “webhooktoken” in the chat and press Enter. Then click Create Webhook.
- Click Create Webhook. In the pop up that appears, we will need to enter the webhook token of the bot.
To fetch the webhook token, click on the Profile icon in the top right corner of the page.
Click Bots & Tools.
Click on Webhook Tokens in the Integrations menu.
Click Generate New Token and copy the generated token.
Paste the token value in the pop-up and click Submit.
Obtain the App Key
You can obtain the App Key of the extension in the following way:
-
Click on the GitHubExt extension from the extensions page in the Cliq developer console, then navigate to the Connectors section.
-
Copy the Sandbox App Key of your extension.
This key will be the value of the appkey parameter in the URL that we will configure on GitHub.
Obtain the Webhook Handler URL
You can obtain the Webhook Handler URL of the extension in the following way:
- Navigate back to your Cliq account and click on your profile picture. Click on Bots & Tools in the menu section.
- Click on the GitHub Bot from your bots list. This will open a side panel. Copy the URL displayed under Incoming WebHook Endpoint.
This will be the baseURL that we will configure on GitHub.
Create a Webhook on GitHub
The complete URL to configure on GitHub is:
baseURL?appkey={{appkey}}&zapikey={{zapikey}}
where baseURL is the webhook handler URL, appkey is the sandbox App Key of your extension, and zapikey is the webhook token generated on Cliq.
For example:
https://cliq.zoho.com/company/org_id/api/v2/githubbot/incoming?appkey={{appkey}}&zapikey={{zapikey}}
Let’s now add this URL on GitHub in the following way:
-
Open your GitHub account and navigate to any one of your repositories.
-
Open your repository’s settings, then click Webhooks -> Add webhook.
- Enter the URL in the format specified above, substituting the values of appkey and zapikey. Configure the webhook as shown below.
You can select the events that you would like to be notified about.
- Click Add webhook.
This webhook will now enable alerts for the configured events in your repository.
Last Updated 2023-12-15 18:54:08 +0530 +0530