Probot: GitHub App Framework

14.3.2 · active · verified Sun Apr 19

Probot is a robust Node.js framework, currently at version 14.3.2, designed for building GitHub Apps to automate and enhance development workflows. It provides a streamlined, event-driven architecture that significantly simplifies interaction with the GitHub API and handling webhook events. Written in TypeScript, Probot ships with comprehensive type definitions, offering full support for TypeScript projects. The project maintains an active development and release cadence, with minor and patch versions frequently released (typically every few weeks) to deliver bug fixes, critical security updates (such as recent `yaml` dependency patches), and new features. Its primary differentiator is abstracting the complexities of GitHub App development, allowing developers to concentrate on core application logic rather than boilerplate API calls, authentication, or webhook infrastructure.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates a basic Probot app written in TypeScript, responding to new issue and pull request events by adding comments. It also includes error handling and shows how to log messages and use environment variables.

import { Probot } from 'probot';

export default (app: Probot) => {
  app.on('issues.opened', async (context) => {
    const issueComment = context.issue({
      body: 'Thanks for opening this issue! We\'ll take a look soon.',
    });
    return context.octokit.issues.createComment(issueComment);
  });

  app.on('pull_request.opened', async (context) => {
    context.log.info(`New pull request opened: ${context.payload.pull_request.html_url}`);
    const prComment = context.issue({
      body: 'Welcome to the party, pull request! Feel free to ask questions if you get stuck.',
    });
    return context.octokit.issues.createComment(prComment);
  });

  app.onError(async (error) => {
    app.log.error(`An error occurred: ${error.message}`);
    // Optionally, send error details to a monitoring service
    // console.error(error);
  });

  // Example of using an environment variable for configuration (optional)
  const GREETING_MESSAGE = process.env.PROBOT_GREETING_MESSAGE ?? 'Hello from Probot!';
  app.log.info(GREETING_MESSAGE);
};

view raw JSON →