Send notifications to Slack
You can find more examples at the Integration with Slack page
Warning: sample URLs!
Please make sure to replace https://hooks.slack.com/services/some/slack/endpoint with your Slack Webhook URL and https://youraccount.tpondemand.com/ with your Targetprocess URL
Basic template
This basic template can be used in order to receive notifications about created, modified and deleted work items.
[
{
"type": "source:targetprocess:EntityChanged",
"entityTypes": [
"Request"
],
"modifications": {
"created": true,
"deleted": true,
"updated": [
"ModifyDate"
]
}
},
{
"type": "action:SendHttpRequest",
"body": {
"type": "concat",
"operands": [
{
"type": "constant",
"value": "{\n \"text\": \""
},
{
"type": "field",
"name": "Name",
"target": {
"type": "field",
"name": "EntityType",
"target": {
"type": "pipelineBlockOutput"
}
}
},
{
"type": "constant",
"value": "/"
},
{
"type": "field",
"name": "Id",
"target": {
"type": "pipelineBlockOutput"
}
},
{
"type": "constant",
"value": " "
},
{
"type": "field",
"name": "EntityUri",
"target": {
"type": "pipelineBlockOutput"
}
},
{
"type": "constant",
"value": " was "
},
{
"type": "field",
"name": "Modification",
"target": {
"type": "pipelineBlockOutput"
}
},
{
"type": "constant",
"value": " by "
},
{
"type": "field",
"name": "FullName",
"target": {
"type": "field",
"name": "Author",
"target": {
"type": "pipelineBlockOutput"
}
}
},
{
"type": "constant",
"value": "\",\n \"username\": \"Targetprocess\"\n}"
}
]
},
"url": {
"type": "constant",
"value": "https://hooks.slack.com/services/some/slack/endpoint"
}
}
]
Information about changed Effort
[
{
"type": "source:targetprocess:EntityChanged",
"entityTypes": [
"UserStory",
"Task",
"Bug"
],
"modifications": {
"created": false,
"deleted": false,
"updated": [
"Effort"
]
}
},
{
"or": [
{
"and": [
{
"value": {
"type": "constant",
"value": "Kanban"
},
"target": {
"name": "Name",
"type": "field",
"target": {
"name": "Project",
"type": "field",
"target": {
"type": "pipelineBlockOutput"
}
}
},
"operator": {
"type": "is"
}
}
]
}
],
"type": "filter:Relational"
},
{
"type": "action:JavaScript",
"script": "const link = `<https://youraccount.tpondemand.com/entity/${args.ResourceId}|${args.Current.Name}>`;\nlet message = ``;\nif (args.Previous.Effort == 0) {\n message = `:black_circle_for_record: Entity# ${args.ResourceId} ${link} was estimated ${args.Current.Effort} points`;\n}\nelse if (args.Current.Effort > args.Previous.Effort) {\n message = `:arrow_up: Entity #${args.ResourceId} ${link}. Effort increased from ${args.Previous.Effort} to ${args.Current.Effort} points`;\n}\nelse {\n message = `Entity #${args.ResourceId} ${link}. Effort decreased from ${args.Previous.Effort} to ${args.Current.Effort} points`;\n}\n\nreturn {\n command: \"SendHttpRequest\",\n payload: {\n url: \"https://hooks.slack.com/services/some/slack/endpoint\",\n body: {\n \"text\": message,\n \"icon_emoji\": \":bee:\",\n \"username\": \"Targetprocess\"\n }\n }\n};"
}
]
Information about changed state
[
{
"type": "source:targetprocess:EntityChanged",
"entityTypes": [
"UserStory",
"Task",
"Bug",
"Feature",
"Epic",
"Request"
],
"modifications": {
"created": true,
"deleted": false,
"updated": [
"EntityState"
]
}
},
{
"or": [
{
"and": [
{
"value": {
"type": "constant",
"value": "Kanban"
},
"target": {
"name": "Name",
"type": "field",
"target": {
"name": "Project",
"type": "field",
"target": {
"type": "pipelineBlockOutput"
}
}
},
"operator": {
"type": "is"
}
}
]
}
],
"type": "filter:Relational"
},
{
"type": "action:SendHttpRequest",
"body": {
"type": "concat",
"operands": [
{
"type": "constant",
"value": "{ \n \"text\": \"Change state for #"
},
{
"type": "field",
"name": "ID",
"target": {
"type": "pipelineBlockOutput"
}
},
{
"type": "constant",
"value": " <"
},
{
"type": "field",
"name": "EntityUri",
"target": {
"type": "pipelineBlockOutput"
}
},
{
"type": "constant",
"value": "|"
},
{
"type": "field",
"name": "Name",
"target": {
"type": "pipelineBlockOutput"
}
},
{
"type": "constant",
"value": "> by "
},
{
"type": "field",
"name": "FullName",
"target": {
"type": "field",
"name": "Author",
"target": {
"type": "pipelineBlockOutput"
}
}
},
{
"type": "constant",
"value": " ["
},
{
"type": "field",
"name": "Name",
"target": {
"type": "field",
"name": "EntityState",
"target": {
"type": "field",
"name": "Previous",
"target": {
"type": "pipelineBlockOutput"
}
}
}
},
{
"type": "constant",
"value": "] -> ["
},
{
"type": "field",
"name": "Name",
"target": {
"type": "field",
"name": "EntityState",
"target": {
"type": "pipelineBlockOutput"
}
}
},
{
"type": "constant",
"value": "]\",\n \"username\": \"Targetprocess\"\n}"
}
]
},
"url": {
"type": "constant",
"value": "https://hooks.slack.com/services/some/slack/endpoint"
}
}
]
A user is assigned to an entity
Don't use any filter if you'd like to post notifications even if the user assigns an entity to himself.
[
{
"type": "source:targetprocess:EntityChanged",
"entityTypes": [
"Assignment"
],
"modifications": {
"created": true,
"deleted": false,
"updated": false
}
},
{
"or": [
{
"and": [
{
"target": {
"type": "field",
"name": "Id",
"target": {
"type": "field",
"name": "Author",
"target": {
"type": "pipelineBlockOutput"
}
}
},
"value": {
"type": "field",
"name": "Id",
"target": {
"type": "field",
"name": "GeneralUser",
"target": {
"type": "pipelineBlockOutput"
}
}
},
"operator": {
"type": "is not"
}
}
]
}
],
"type": "filter:Relational"
},
{
"url": {
"type": "constant",
"value": "https://hooks.slack.com/services/some/slack/endpoint"
},
"body": {
"type": "concat",
"operands": [
{
"type": "constant",
"value": "{ \n \"text\": \""
},
{
"type": "field",
"name": "Name",
"target": {
"type": "field",
"name": "EntityType",
"target": {
"type": "field",
"name": "Assignable",
"target": {
"type": "pipelineBlockOutput"
}
}
}
},
{
"type": "constant",
"value": " #"
},
{
"type": "field",
"name": "Id",
"target": {
"type": "field",
"name": "Assignable",
"target": {
"type": "pipelineBlockOutput"
}
}
},
{
"type": "constant",
"value": " "
},
{
"type": "field",
"name": "Name",
"target": {
"type": "field",
"name": "Assignable",
"target": {
"type": "pipelineBlockOutput"
}
}
},
{
"type": "constant",
"value": " assigned to "
},
{
"type": "field",
"name": "FirstName",
"target": {
"type": "field",
"name": "GeneralUser",
"target": {
"type": "pipelineBlockOutput"
}
}
},
{
"type": "constant",
"value": " "
},
{
"type": "field",
"name": "LastName",
"target": {
"type": "field",
"name": "GeneralUser",
"target": {
"type": "pipelineBlockOutput"
}
}
},
{
"type": "constant",
"value": " by "
},
{
"type": "field",
"name": "FullName",
"target": {
"type": "field",
"name": "Author",
"target": {
"type": "pipelineBlockOutput"
}
}
},
{
"type": "constant",
"value": " \",\n \"username\": \"Targetprocess\",\n}"
}
]
},
"type": "action:SendHttpRequest"
}
]
Available fields
In the filter and template, you can use Fields of Assignment resource.
Updated 4 months ago