Search code examples
bashmacosslackslack-api

How to use slack out going webhooks to send text to an external computer


I have set up outgoing webhooks in slack. I would like to put text in a certain channel and be able to send that text to my computer. I would also like if this was possible to send the text/message from mobile slack. I am using a mac so if i can send the information to my computer from slack or do I need to set up a bash script to curl the website and get the info.


Solution

  • Yes, this is possible to achieve with outgoing webhooks (or better use Events API, since outgoing webhooks are a legacy feature).

    To make that work you need:

    1. Your computer needs to be reachable on the Internet
    2. a webserver running on your computer
    3. an app running on your computer to receive the Slack requests

    1) can be achieved by either opening up the necessary ports on your router / firewall or by using a VPN tunnel like ngrok. I would recommend the later, since its way more easier to run securely. I can specifically recommend the ngrok service, which also runs on MAC and has a free plan.

    2) All Slack requests are http based, so you need a webserver. I would recommend installing the standard AMP package (Apache, MySql, PHP), which is called MAMP (Mac AMP) for the Mac. But other webservers will work too.

    3) You need an app to receive and process requests from Slack. That can be a simple PHP script.

    For details and examples on how to create apps for Slack check out the excellent official documentation and the official tutorial.

    Btw.: this is the same setup that Slack developers (like myself) are using for developing and testing Slack apps on their local development computer.