Skip to content

Instantly share code, notes, and snippets.

@venetucci
Last active November 25, 2016 07:57
Show Gist options
  • Save venetucci/e5721362ca0be863a4c6a4606b6f109b to your computer and use it in GitHub Desktop.
Save venetucci/e5721362ca0be863a4c6a4606b6f109b to your computer and use it in GitHub Desktop.
function postResponse(channel, userName, topic, title, author, description, link) {
var payload = {
"channel": "#" + channel,
"username": "New item added to reading list",
"icon_emoji": ":grin:",
"link_names": 1,
"attachments":[
{
"fallback": "This is an update from a Slackbot integrated into your organization. Your client chose not to show the attachment.",
"pretext": "@" + userName + " added a new item to the reading list",
"mrkdwn_in": ["pretext"],
"color": "#76E9CD",
"fields":[
{
"title":"Topic",
"value": topic,
"short":false
},
{
"title":"Title",
"value": title,
"short":false
},
{
"title":"Author",
"value": author,
"short":false
},
{
"title":"Description",
"value": description,
"short": false
},
{
"title":"Link",
"value": link,
"short": false
}
]
}
]
};
var url = '[INCOMING WEBHOOK URL]';
var options = {
'method': 'post',
'payload': JSON.stringify(payload)
};
return UrlFetchApp.fetch(url,options);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment