c# - Slack Event Subscription -


i'm trying create bespoke functionality software team , thought of great solution using slack event subscriptions. problem is, having problems getting event information after...so far have managed configure slack call wcf service, however, 'event' parameter includes information after null.

here have far:

[servicecontract] public interface islacktrelloservice {     [operationcontract]     [webinvoke(method = "post", uritemplate = "slackpost", requestformat = webmessageformat.json, bodystyle = webmessagebodystyle.wrapped, responseformat = webmessageformat.json)]     string slackpost(string type, string token, string challenge, string team_id, slackevent slackevent); } 

the concrete implementation:

 public class slacktrelloservice : islacktrelloservice {     public string slackpost(string type, string token, string challenge, string team_id, slackevent slackevent)     {         return challenge;     } } 

the slackevent class:

[jsonobject(id = "event", description = "event", title = "event")] public class slackevent {     [jsonproperty(propertyname = "type")]     public string type { get; set; }      [jsonproperty(propertyname = "event_ts")]     public string eventtimestamp { get; set; }      [jsonproperty(propertyname = "user")]     public string user { get; set; }      [jsonproperty(propertyname = "ts")]     public string timestamp { get; set; }      [jsonproperty(propertyname = "item")]     public string item { get; set; } } 

now, slackevent object problematic bit of code because want contain information sent slack according this documentation. other parameters populated correctly, not slackevent object :(

at first thought because parameter name didn't match, using @event (since event keyword in c#) didn't seem work. i'm not sure if using newtonsoft json library incorrectly, or if there else missing.

edit: new method capture data in correct format

string slackpost(string token, string team_id, string api_app_id, slackevent slackevent, string type, string[] authed_users, string event_id, string event_time); 

slackevent structure:

[jsonobject("event")] public class event {     [jsonproperty(propertyname = "type")]     public string type { get; set; }      [jsonproperty(propertyname = "channel")]     public string channel { get; set; }      [jsonproperty(propertyname = "user")]     public string user { get; set; }      [jsonproperty(propertyname = "text")]     public string text { get; set; }      [jsonproperty(propertyname = "ts")]     public string timestamp { get; set; } } 

by c# bit rusty, can understand looks if slacktrelloservice class implementation incomplete.

slack sends 2 different requests events: verification handshake , actual event. class seams aim cover both types in 1 class, think not work way implemented.

the verification handshake used once during event subscription , not contain event information. looks this: (from official documentation)

{     "token": "jhj5dzrvak7zwhhjryzwjbdl",     "challenge": "3ezbrw1abm2rzgrnfdxv2595e9cy3gmdalwmmhkvfxo7tyxaym8p",     "type": "url_verification" } 

you app need reply correctly verification handshake enable successful event subscription.

the actual events send later this: (again official documentation)

 {         "token": "z26ufbvr1xhjedhe1oqio6t8",         "team_id": "t061eg9rz",         "api_app_id": "a0ffv41kk",         "event": {                 "type": "reaction_added",                 "user": "u061f1eur",                 "item": {                         "type": "message",                         "channel": "c061eg9sl",                         "ts": "1464196127.000002"                 },                 "reaction": "slightly_smiling_face"         },         "event_ts": "1465244570.336841",         "type": "event_callback",         "authed_users": [                 "u061f7aur"         ] } 

as can see not have challenge property, instead many others.

you seam return challenge in class, not actual event info.

so here suggestions:

  1. make sure have subscribed events within slack app. if not verification handshake not include event.

  2. make separate implementations deal verification handshake , event requests


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -