8000 GitHub - asksven/azure-functions-slack-bot: A nodejs Azure Function to post to Slack
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Feb 15, 2025. It is now read-only.

asksven/azure-functions-slack-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 

Repository files navigation

azure-functions-slack-bot

A nodejs Azure Function to post to Slack

1 Pre-requisites

  • You will need an Azure subscription. You can get one for free here
  • your brain

2 TLDR;

  1. Fork this project
  2. Create an Azure function App from the portal (as at this time Azure Functions are still in preview you may want to go here
  3. Set the forked repo as your deployment source (gear icon)
  4. Create a function called Slackbot (or whatever name you have changed the function into in your fork)
  5. wait for the repo to sync
  6. Tricky part: for whatever reason Azure Functions do not run npm install. Therefore you need to go to Function app Settings - Kudu and open the console, go to site/wwwroot/Slackbot and run npm install from the console command-line
  7. go to the Function app settings
  8. Create a Slack Webhook
  9. Add an App Setting named SLACK_URL to your Azure Function, pointing to the Slack Webhook
  10. Test the function by adding a payload (HTTP POST) to the functions's Run body
{
    "channel": "<webhook-channel>",

    "username": "<bot-name>",
    "text": "This is your last notice",
    "icon_url": "",
    "icon_emoji": ":lightning_cloud:",
    "fallback": "Upgrade your client",
    "notifications": [
    {
        "type": "error",
        "title": "Error title",
        "text": "This is an error notification"
    },
    {
        "type": "warn",
        "title": "Warn title",
        "text": "This is a warning notification"
    },
    {
        "type": "info",
        "title": "Info title",
        "text": "This is an info notification"
    }]
}

#3 Invoking

Pick your poison. Here a Powershell-snippet if you need some help to get going:

# tested with PS 5.1
$url = "<your-azure-function-endpoint-goes-here>"

$body = '{ "channel": "<channel>", "username": "<botname>", "text": "This is your last notice", "icon_url": "", "icon_emoji": ":lightning_cloud:", "fallback": "Upgrade your client", "notifications": [{ "type": "error", "title": "Error title", "text": "This is an error notification" }, { "type": "warn", "title": "Warn title", "text": "This is a warning notification" }, { "type": "info", "title": "Info title", "text": "This is an info notification" }] }'
	

Invoke-RestMethod $url -Body $body -Method Post -ContentType 'application/json'

About

A nodejs Azure Function to post to Slack

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0