Slack.com integration into Robot Framework

120 views
Skip to first unread message

OliverNZ

unread,
Jul 23, 2014, 6:33:21 PM7/23/14
to robotframe...@googlegroups.com
Hi,

I thought I'd share this simple connector. This Library allows you to post comments to a channel on Slack.com. You will need to have an incoming webhook created for this (https://api.slack.com/). I use it to post test start and end and some other useful information, sothat it is obvious to the team what is happening at any point in time. 


"""
Library for integrating into Slack.com 
2014 Oliver Erlewein
"""

import requests
import json

def Slack_Post(webhook, message, icon=None):
    """Posts a comment to Slack.com
    """
    headers={'Content-Type':'application/json'}
    if icon==None:
       data={'text': message}
    else:
       data={'text': message, 'icon_emoji': icon }
    data_json=json.dumps(data)
    response = requests.post( webhook, data=data_json, headers=headers)
    return response.status_code

Cheers Oliver
Reply all
Reply to author
Forward
0 new messages