Webhooks & Asp.Net

Post on 15-Apr-2017

713 views 5 download

Transcript of Webhooks & Asp.Net

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

AUTOMATION SERVICEJan Vanuytrecht

WEBHOOKS?• Pattern to connect web services

Trigger Action

Retry

Secret

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

ASP.NET WEBHOOKS: RECEIVER

Instant Queued

ASP.NET WEBHOOKS: SENDER

Subscriptions Notifications to set of subscribers Retry policy

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

RECEIVER: SLACK

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

RECEIVER: GENERICJSON (IFTTT)

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

SEND TO ZAPIER

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