Template Content
About the template
About ScriptRunner Connect
What is ScriptRunner Connect?
Can I try it out for free?
Yes. ScriptRunner Connect comes with a forever free tier.
Can I customize the integration logic?
Absolutely. The main value proposition of ScriptRunner Connect is that you'll get full access to the code that is powering the integration, which means you can make any changes to the the integration logic yourself.
Can I change the integration to communicate with additional apps?
Yes. Since ScriptRunner Connect specializes in enabling complex integrations, you can easily change the integration logic to connect to as many additional apps as you need, no limitations.
What if I don't feel comfortable making changes to the code?
First you can try out our AI assistant which can help you understand what the code does, and also help you make changes to the code. Alternatively you can hire our professionals to make the changes you need or build new integrations from scratch.
Do I have to host it myself?
No. ScriptRunner Connect is a fully managed SaaS (Software-as-a-Service) product.
What about security?
ScriptRunner Connect is ISO 27001 and SOC 2 certified. Learn more about our security.
This template demonstates how to check if the new issue that was created in Jira Cloud is "a critical bug", if it is, then send a message to a configured Slack channel.
Parameters
and configure parameters to meet you needs.Create a new issue in Jira Cloud that matches a condition for "critical bug", after successful event processing a new message should be sent to the configured Slack channel.
import { IssueCreatedEvent } from '@sr-connect/jira-cloud/events';
import Slack from './api/slack';
/**
* This function checks if the new issue that was created is a critical bug, and if it is then sends a message to pre-defined Slack channel.
*
* @param event Object that holds Issue Created event data
* @param context Object that holds function invocation context data
*/
export default async function (event: IssueCreatedEvent, context: Context) {
if (context.triggerType === 'MANUAL') {
console.error('This script is designed to be triggered externally or manually from the Event Listener. Please consider using Event Listener Test Event Payload if you need to trigger this script manually.');
return;
}
const { SLACK_CHANNEL, ISSUE_TYPE_NAME, ISSUE_PRIORITY_NAME } = getEnvVars(context);
// Check if the Issue is critical bug
if (event.issue.fields.issuetype?.name === ISSUE_TYPE_NAME && event.issue.fields.priority?.name === ISSUE_PRIORITY_NAME) {
// If it is, then log out the issue key
console.log(`Critical bug was created: ${event.issue.key}`);
// And send a message to pre-defined Slack channel
await Slack.Chat.postMessage({
body: {
channel: SLACK_CHANNEL,
text: `New critical bug was created - Key: ${event.issue.key} - Reporter: ${event.issue.fields.reporter?.displayName ?? 'Unknown'} - Summary: ${event.issue.fields.summary}`
}
});
}
}
interface EnvVars {
SLACK_CHANNEL: string;
ISSUE_TYPE_NAME: string;
ISSUE_PRIORITY_NAME: string;
}
export function getEnvVars(context: Context) {
return context.environment.vars as EnvVars;
}