Webhooks & Asp.Net

12
N USE ASP.NET WEBHOOKS TO CONNECT AN API TO A WEB- AUTOMATION SERVICE Jan Vanuytrech t

Transcript of Webhooks & Asp.Net

Page 1: Webhooks & Asp.Net

NUSE ASP.NET WEBHOOKS TO CONNECT AN API TO A WEB-

AUTOMATION SERVICEJan Vanuytrecht

Page 2: Webhooks & Asp.Net

WEBHOOKS?• Pattern to connect web services

Trigger Action

Retry

Secret

Page 3: Webhooks & Asp.Net

AUTOMATION SERVICES?• Connect two services• IFTTT and Zapier• Trigger (Github: comment or mention, pull request)• Action (Slack : new message in channel)

Page 4: Webhooks & Asp.Net

ASP.NET WEBHOOKS: RECEIVER

Instant Queued

Page 5: Webhooks & Asp.Net

ASP.NET WEBHOOKS: SENDER

Subscriptions Notifications to set of subscribers Retry policy

Page 6: Webhooks & Asp.Net

RECEIVER: SLACK• Web API Project• Nuget package : Microsoft.AspNet.WebHooks.Receivers.Slack"• WebApiConfig > config.InitializeReceiveSlackWebHooks();• Attribute routing = on!

• Slack > Custom integrations• Enter url https://<host>/api/webhooks/incoming/slack , copy token

• Web.config: add appSetting MS_WebHookReceiverSecret_Slack with token• Code: WebhookHandler

Page 7: Webhooks & Asp.Net

RECEIVER: SLACK

Page 8: Webhooks & Asp.Net

RECEIVER: GENERICJSON• Nuget package: Microsoft.AspNet.WebHooks.Receivers.Generic • WebApiConfig > config. InitializeReceiveGenericJsonWebHooks();• Web.config: add appSetting MS_WebHookReceiverSecret_GenericJson with token

Page 9: Webhooks & Asp.Net

RECEIVER: GENERICJSON (IFTTT)

Page 10: Webhooks & Asp.Net

SEND TO ZAPIER• Create ZAP• Choose Webhooks• Copy URL• Send http request to Zapier’s custom provided URL

Page 11: Webhooks & Asp.Net

SEND TO ZAPIER

Page 12: Webhooks & Asp.Net

SOURCES• http://docs.asp.net/projects/aspnetwebhooks/en/latest/receiving/index.html • @vanuyja• @NaratoBE