Created
June 12, 2015 18:53
-
-
Save darkpixel/1effa7175d3850c5e8b5 to your computer and use it in GitHub Desktop.
RT post to Slack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use HTTP::Request::Common qw(POST); | |
use LWP::UserAgent; | |
use JSON; | |
my $webhook_url = 'your-webhook-url'; | |
my $default_channel = '#your-channel'; | |
my $ua = LWP::UserAgent->new; | |
$ua->timeout(15); | |
my $payload = { | |
channel => $default_channel // $default_channel, | |
username => 'RTbot', | |
icon_emoji => ':uit-ticket:', | |
text => '', | |
}; | |
$payload->{text} .= "New ticket <https://my-rt-server.tld/Ticket/Display.html?id=" . $self->TicketObj->Id . "|" . $self->TicketObj->Id . "> from " . $self->TicketObj->RequestorAddresses . ": " . $self->TicketObj->Subject; | |
my $req = POST("$webhook_url", ['payload' => encode_json($payload)]); | |
my $resp = $ua->request($req); | |
if ($resp->is_success) { | |
print ''; | |
} else { | |
RT->Logger->error($resp->status_line); | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment