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.
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.
$ npm install probot-messages
Required permissions
- Issues - Read & Write
- Repository metadata - Read-only
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.'}
);
}
}
});
};
Messages repository maintainers by submitting an issue.
app
Object app instancecontext
Object event contexttitle
string issue title,{appName}
and{appUrl}
are optional placeholdersmessage
string issue content,{appName}
and{appUrl}
are optional placeholdersoptions
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, default7
)options.owner
string? owner of the repository (optional, default value inferred fromcontext
)options.repo
string? repository (optional, default value inferred fromcontext
)
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
Details of the message.
Type: Object
owner
string owner of the repositoryrepo
string repositoryissue
number issue number of the messagecomment
number? comment ID of the updateisNew
boolean indicates if the issue was newly created
Copyright (c) 2018-2021 Armin Sebastian
This software is released under the terms of the MIT License. See the LICENSE file for further information.