Git Product home page Git Product logo

azure-functions-slack-bot's Introduction

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'

azure-functions-slack-bot's People

Contributors

asksven avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.