Join us for office hours !

Hello World

A Probot app is just a Node.js module that exports a function:

module.exports = robot => {
  // your code here

The robot parameter is an instance of Robot and gives you access to all of the bot goodness.

robot.on will listen for any webhook events triggered by GitHub, which will notify you when anything interesting happens on GitHub that your app wants to know about.

module.exports = robot => {
  robot.on('issues.opened', async context => {
    // A new issue was opened, what should we do with it?

The context passed to the event handler includes everything about the event that was triggered, as well as some helpful properties for doing something useful in response to the event. context.github is an authenticated GitHub client that can be used to make API calls, and allows you to do almost anything programmatically that you can do through a web browser on GitHub.

Here is an example of an autoresponder app that comments on opened issues:

module.exports = robot => {
  robot.on('issues.opened', async context => {
    // `context` extracts information from the event, which can be passed to
    // GitHub API calls. This will return:
    //   {owner: 'yourname', repo: 'yourrepo', number: 123, body: 'Hello World!}
    const params = context.issue({body: 'Hello World!'})

    // Post a comment on the issue
    return context.github.issues.createComment(params);

Find a mistake or want to help improve this documentation? Suggest changes on GitHub

Get occasional updates on new apps & features.


with by @bkeepers

Code licensed ISC Docs licensed CC-BY-4.0