Build and receive a new incoming idle website

I just created a channel via Slack Api using the channel.create method. How do I add an incoming webhook and get the url programmatically? I have other tools that will use it further.

+2


source to share


2 answers


You can't create new incoming webhooks programmatically, but you don't need to. Just override the channel property in the existing inbound webhook for your current Slack team to use the new channel.

Example:



{
  "text": "This is a line of text.\nAnd this is another one.", 
  "channel": "channel-name"
}

      

Please note that this will only work for incoming websites defined using custom integrations, not those defined as part of the Slack app.

+1


source


data = {
    "attachments": [
        {
            "author_name": "[Alert] - A Jenkins Job is Already Running!",
            "color": "#36a64f",
            "title": "Android Jenkins Job",
            "title_link": "http://xx.xxx.xxx.xxx/job/Mobile_Regression/",
            "footer": "Android Build Attempted",
            "ts": time.time()
        }
    ],
    "channel": "#channel"
}
json_params_encoded = json.dumps(data)
slack_response = requests.post(url=hook_url, data=json_params_encoded, headers={"Content-type": "application/json"})

      



0


source







All Articles