Get Hooked on Webhooks: RESTful Integration with a World Wide Web of Services
-
Upload
salesforce-developers -
Category
Technology
-
view
866 -
download
0
Transcript of Get Hooked on Webhooks: RESTful Integration with a World Wide Web of Services
Salesforce 2015 Get Hooked on Webhooks
Joseph Ucuzoglu [email protected]
RESTFul integration with a world wide web of services
Daisy Garcia [email protected]
Learn what webhooks are and why we should care
Demonstrate a powerful tool for creating webhook integrations
Show both sides of the equation (creating the webhook for Salesforce and consuming that webhook via the Salesforce API)
Provide you with PDF guides you can follow along with after the presentation
Our Objectives
Don’t Take Notes! ● Too much information
● PDF guides will be posted to the Chatter feed when the presentation completes.
● Relax and have a good time
Electronic Guides
https://sites.google.com/site/df2015guides/
Understanding Webhooks Your first step to becoming a webhooker
AKA Web Callback; AKA HTTP Push API
A simple event-notification via HTTP POST
Payload Formats (Form Data, JSON or XML)
What are they? Webhooks
1. Consumer is responsible for polling the provider.
2. Consumer must create communication according to API specification.
3. Consumer must create code to consume API response.
On average over 98.5% of polls are wasted *http://resthooks.org/
How they work Standard API’s
Provider
Consumer
API
API
1. Provider makes an HTTP request (POST) to Consumer endpoint when an event occurs.
2. Consumer must write the code to handle the HTTP request from provider
Zapier spends 66x more resources on polling than on webhooks.
*https://zapier.com/engineering/introducing-resthooksorg/
How they work Webhooks
Provider
Consumer
API
“I want my Google Form posts to populate records in Salesforce”
Our solution
HTTP POST
Zapier the ultimate app connector
DIY Webhooks 4 Salesforce
Step 1 - Collect the data
Step 1 - Collect the data The Standard Google form
Standard Google Form
3 Fields
Submits results to Google Sheet
All form-fields are represented.
Labels show in the first row.
Form submissions fill in each subsequent row.
Google also includes a Timestamp field.
Step 1 - Collect the data The Google Sheet
Step 2 - Process the data
Step 2 - Process the data Zapier (Step 1) - Trigger & Action
Step 2 - Process the data Zapier (Step 2-3) Connect to Accounts
Step 2 - Process the data Zapier (Step 4) Filter / Select Results
Step 2 - Process the data Zapier (Step 5) Matching & Mapping
Step 2 - Process the data Zapier (Step 6) Testing [Google Sheets]
Step 2 - Process the data Zapier (Step 6) Testing [ Zapier Webhook]
RequestBin
Done testing? Set the URL to point to Salesforce
3. Catching and Processing the Data
Set up a public REST endpoint w/Salesforce
Create the APEX REST Class
Modify Public Guest User Security Settings
Test your webhook using an API testing tool
Catching Webhooks w / Salesforce
Public REST APIs w/ Salesforce
https://developer.salesforce.com/blogs/developer-relations/2012/02/quick-tip-public-restful-web-services-on-force-com-sites.html
Generates API Endpoint Handles object dynamically Handles fields dynamically Less than 40 lines of code
The Apex Rest Class
The Apex REST Class
The Apex REST Class
@HttpDelete
@HttpGet
@HttpPatch
@HttpPost
@HttpPut
Make sure the guest user has permission to access to APEX script Guest User Profile Permissions
Useful Tools / Resources for Testing
Hurl.it
https://www.hurl.it/ http://requestb.in/
RequestBin
Hurl.It
The happy ending - Our form post inserted in Salesforce
Recap & Next Steps
Webhooks are becoming increasingly popular You can use a tool like Zapier to create your own webhooks Make sure that your API endpoint is publicly accessible Tools like RequestBin and Hurl.It make development easier Dig into the resources we have provided you to experiment and learn more.
Resources Available in the session Chatter feed & Website address below
https://sites.google.com/site/df2015guides/
Thank you