Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<when condition="@(context.Variables.GetValueOrDefault<bool>("isEventGridNotification"))">
<send-one-way-request mode="new">
<set-url>https://hooks.slack.com/services/{{slack-key}}</set-url>
<set-method>POST</set-method>
<set-body>@{
var events = context.Request.Body.As<string>();
JArray a = JArray.Parse(events);
var eventGridData = a.First["data"];
var station = eventGridData["station"];
var artist = eventGridData["artist"];
var song = eventGridData["song"];
return new JObject(
new JProperty("username", station),
new JProperty("icon_emoji", ":musical_note:"),
new JProperty("text", String.Format("Just added: {0}, {1}",
song, artist))
).ToString();
}</set-body>
</send-one-way-request>
<return-response>
<set-status code="200" reason="OK" />
</return-response>
</when>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment