Create an Extension on Cliq

You can now configure the extension in Cliq. As mentioned in the introduction, this Cliq extension will bundle all the development components that we will require for this setup. You can learn about Cliq extensions in detail from the Cliq help documentation.

We will add the following Cliq components to be bundled in the extension:

  • Command for issues: A command handled by the command_handler.py class that fetches the last ten issues raised in a specific repository.
  • Command for commits: A command handled by the command_handler.py class that fetches the last ten commits made in a specific repository.
  • Button function to authenticate the webhook token: A function handled by the function_handler.py class that is executed when a button is clicked in the chat bot. This function authenticates the webhook token for GitHub.
  • GitHub bot: A chat bot handled by the bot_handler.py class that enables you to execute these commands. The bot also includes a menu action that lists your existing repositories, and enables you to select a repo to execute a command for.

Please make sure to follow the below steps to configure the Cliq extension:

  1. Log in to your Cliq account and open the Cliq developer console. Click Create Extension.

create_extension

  1. Enter the name of the extension as “GitHubExt” and enter a description for it as shown in the screenshot below.

Select the execution type as Catalyst Function. Choose your organization in which you have created the project in this step. Select the project GitHubBot and the function git_hub_bot_function from the dropdown list. This allows the extension to invoke the function whenever any of the components in the extension are accessed.

We can now proceed to add components that we will require for this extension.

Select the Catalyst project GitHubBot that we created for this tutorial and the GithubExtension function from the dropdown lists. This lets the extension invoke the function whenever any of the components in the extension are accessed.

We can now add the components that we will require for this extension.

extension_details

  1. Click Add components, then click Command.

add_component

  1. Enter the command’s name as “issues”. Provide a hint for the command as shown in the description below.

issues

In the Command Handlers section, choose Attachments, Chat, Location and User for the Execution Handler. Enable the Suggestion Handler and allow access for Chat, Location and User. Configure the command to execute on selecting only one suggestion. Click Add.

issue_details

  1. Similarly, click the Add components button in the extension configuration again, then click Command. Provide the name of the command as “commits”. Make sure to implement the same configuration as that of the issues command here as well. Click Add.

commits

  1. Next, we will add a Function component. Provide the name of the function as “authenticate”. Give a description for the function as shown in the screenshot below.

Select the Function Type as Button and click Add.

add_function

  1. Finally, we will add a Bot component and configure the name as “GitHub Bot”. Give a description as shown in the screenshot below.

Enable Channel Participation and select both Listen to messages and Send messages.

add_bot

Enable all the handlers, and select all the enabled checkboxes. This will enable the bot to acknowledge messages in the chat and the webhook requests received from GitHub.

You must also add a bot menu action Repos that lists and select all the checkboxes.

add_bot

Now, we have added all the required components for the Cliq Extension.

components

Note: Ensure that you have given the same component names as specified, because we have configured the same names in the function code.
  1. Click Create Extension in the extension configuration page and the created extension will be listed in the Cliq developer console under the Cliq Extensions section.

extension_page

Note: Since we have hardcoded the Personal Access token to access the GitHub API in the GithubConstants.py class, it is not advisable to publish this extension, as the code contains a confidential token.

The Cliq bot will now be available in your Cliq account. The issues and commits commands, along with the Repos menu action will work in the bot.

Before you test these commands, you must also enable alerts to be received automatically whenever a commit is pushed to one of the repositories in the GitHub account using a webhook.

Last Updated 2023-12-15 18:54:08 +0530 +0530

RELATED LINKS

Integration Functions