Skip to content
Probot extension for communicating with repository maintainers
JavaScript Dockerfile Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.ci
.github
src
.gitignore
.nvmrc
.prettierignore
.prettierrc
.travis.yml
CHANGELOG.md
LICENSE
README.md
docs.yml
package.json
yarn.lock

README.md

Probot Messages

Build Status Version

A Probot extension for communicating with repository maintainers. It is used for delivering messages that require user action to ensure the correct operation of the app, such as configuring the app after installation, or fixing configuration errors.

Supporting the Project

The continued development of Probot Messages is made possible thanks to the support of awesome backers. If you'd like to join them, please consider contributing with Patreon, PayPal or Bitcoin.

How It Works

A new issue is opened for messages that don't already have an open issue, otherwise an optional update is posted on the existing issue in the form of a comment.

Usage

$ npm install probot-messages

Required permissions

  • Issues - Read & Write
  • Repository metadata - Read-only

Examples

Notify maintainers about additional configuration steps.

const sendMessage = require('probot-messages');

module.exports = app => {
  app.on('installation_repositories.added', async context => {
    for (const item of context.payload.repositories_added) {
      const [owner, repo] = item.full_name.split('/');
      await sendMessage(
        app,
        context,
        '[{appName}] Getting started',
        'Follow these steps to configure the app...',
        {owner, repo}
      );
    }
  });
};

Notify maintainers about configuration errors.

const sendMessage = require('probot-messages');

module.exports = app => {
  app.on('push', async context => {
    const configFile = 'config.yml';
    try {
      const config = await context.config(configFile);
    } catch (error) {
      if (error.name === 'YAMLException') {
        await sendMessage(
          app,
          context,
          '[{appName}] Configuration error',
          '[{appName}]({appUrl}) has encountered a configuration error in ' +
            `\`${configFile}\`.\n\`\`\`\n${error.toString()}\n\`\`\``,
          {update: 'The configuration error is still occurring.'}
        );
      }
    }
  });
};

API

sendMessage

Messages repository maintainers by submitting an issue.

Parameters

  • app Object app instance
  • context Object event context
  • title string issue title, {appName} and {appUrl} are optional placeholders
  • message string issue content, {appName} and {appUrl} are optional placeholders
  • options Object? options (optional, default {})
    • options.update string? update to post as a comment, {appName} and {appUrl} are optional placeholders, no update is posted if the value is falsy or the issue is locked (optional, default '')
    • options.updateAfterDays number? post update only if the issue had no activity in this many days (optional, default 7)
    • options.owner string? owner of the repository (optional, default value inferred from context)
    • options.repo string? repository (optional, default value inferred from context)

Examples

const sendMessage = require('probot-messages');

module.exports = app => {
  app.on('issue_comment.created', async context => {
    await sendMessage(app, context, 'Title', 'Message');
  });
};

Returns Promise<Message> Promise that will be fulfilled with a Message object

Message

Details of the message.

Type: Object

Properties

  • owner string owner of the repository
  • repo string repository
  • issue number issue number of the message
  • comment number? comment ID of the update
  • isNew boolean indicates if the issue was newly created

License

Copyright (c) 2018-2019 Armin Sebastian

This software is released under the terms of the MIT License. See the LICENSE file for further information.

You can’t perform that action at this time.