Send stuck stories to Slack

πŸ“˜

How to apply this rule?

2299

🚧

Warning: sample URLs!

Please make sure to replace https://hooks.slack.com/services/xxxxx/yyyyyy/zzzzzzzzztGRAKwHLfm4kw with your Slack Webhook URL and https://youraccount.tpondemand.com/ with your Targetprocess URL

Filter by project.id is optional.

[
  {
    "type": "source:schedule",
    "schedule": {
      "kind": "interval",
      "unit": "hour",
      "value": 24
    }
  },
  {
    "type": "action:JavaScript",
    "script": "const api = context.getService(\"targetprocess/api/v2\");\nconst stories = await api.queryAsync(\"UserStories\", {\n  select: \"{id, name}\",\n  where: `project.id=3398 and LastStateChangeDate <= Today.AddDays(-14) and endDate == null`\n});\n\nconst links = stories.map(story => {\n  return `<${args.accountBaseUrl}${story.id}|${story.name}>`;\n});\n\n//IMPORTANT: Update Slack link below\nreturn {\n  command: \"SendHttpRequest\",\n  payload: {\n    url: \"https://hooks.slack.com/services/xxxxx/yyyyyy/zzzzzzzzztGRAKwHLfm4kw\",\n    body: {\n      text: `Stuck stories:\\n ${links.join('\\n')}`,\n      username: \"TP\",\n      icon_emoji: \":bangbang:\"\n    }\n  }\n};"
  }
]