Chubot is a chat bot in the Slack platform, for REST-API programmers. Chubot is programmed in node JS, runs on the slack platform and uses POSTGRES-SQL databases.
- Video Presentation
- Introduction
- Primary Features & Screenshots
- Limitations and future work
- Deployment
Here is a link to the video presentation, demonstrating the entire project.
Often developers use REST API requests in their projects when interacting within a platform. For example, many use Github - REST API requests to interact with Github for their version control or source code management needs. Coding REST-API requests into large projects/automated processes requires referring lengthy pages of online documentation to find the proper code-syntax or to find definitions of headers/parameters used in the REST API requests. More importantly, this process is often redundant when developers write lots of similar API requests in their projects. Hence, this process is time consuming for developers and provides an opportunity for automation.
Automating this process using a bot saves a lot of time and helps reduce developer frustration. This also frees the developer from opening many browser windows to refer documentation materials online, thereby clearing a lot of clutter on the developer’s desktop.
Chubot is a chat bot that assists it's users (software developers) by having conversations with them. Chubot has the following important functions:
- It automates the process of searching a platform's support documentation for a code-syntax (or) skeleton code of a REST-API operation/function.
- It finds definitions and explanations of REST API headers/parameters (Eg: JSON headers used in GET/POST methods).
- It also sets required header values in the replies (node.js function code for a REST API operation), if specified by the user.
A developer can simply ask chubot for a specific REST-API request code and chubot will reply with a link to a Github gist containing the requested code in the form of a node.js function. Hence, chubot may be classified as a support bot.
Chubot supports Github and Wordpress platforms as of version 1.0 and can be explanded into other REST-API compatible platforms in furture versions.
Chubot has three primary features:
- Saving a user's username, token and the API URL for a platform (currently Github & Wordpress).
- Generating a node.js function for a REST API request which is then posted as a Github gist.
- Providing definitions for headers/parameters used in REST API requests.
This screenshot shows chubot saving a user's Github and WordPress token. Later, chubot replaces the token values in the generated node.js functions (Feature #2) with this value. Similarly, the user can store their username and URL for every platform supported by chubot.
PART 1: NO PARAMETERS IN REQUEST
This screenshot shows a user asking Chubot for the code to a function which can list all comments in WordPress. Chubot generates the function and posts it as a Github gist and then returns the URL of the gist to the user with a small preview of the function.
PART 2: MULTIPLE PARAMETERS IN REQUEST
This screenshot shows a user asking Chubot for the code to a function which can list issues in a Github repo. It should be noted that the user has passed values for two parameters in the GET request. This informs chubot to set the passed values to the appropriate headers/parameters when generatng the code for the node.js function. As earlier, chubot responds with the gist URL along with a small preview.
It can be seen that Chubot has replaced the default value for state
and sort
parameters with the values that were passed in the user's request message.
This screenshot shows a user asking Chubot to define the parameter has_issues
and Chubot responding with the Name, Type and Definition of has_issues
.
One limitation is that Chubot doesn't verify the validity of the token provided by the user. It simply accepts the token values specified by the user and replaces it with the default values in it's code generation process.
Currently Chubot (v1.0) supports REST API requests in Github and WordPress only. Future work can be focused on including support for other REST API compatible platforms. This can be done without modifying chubot's implementation (code) and just adding required documentation records in the database.
Lastly, there is one more area that could be addressed in the future and that is the storage of skeleton code (used in the function code generation process) in the database. Currently the skeleton code for each function is directly inserted into the database (for each REST API request) and they are not dynamically generated although the parameters alone are dynamically modified. In the future, Chubot can be programmed to include artificial intelligence methods to support this feature. Addition of one or more database tables may be needed for mapping each REST API request to it's parameters and this should be sufficient to allow complete dynamic code generation.
Chubot was deployed into Amazon Web Services EC2 instance using an Ansible Playbook.