Anyone who has ever built a web application has surely felt the need to add features. You need to user management, email, payments, the list goes on and on. It isn’t too long before you realize that you’re re-inventing the wheel time and time again. Even worse, you’re running into problems that have already been solved!
For the sake of this post, I’ll use email as the example. You start with the simple transactional emails to confirm user registration or reset a password, but it isn’t too long before you think, “hey I’d like to allow my users to email all of their customers from time to time.”
Now you need to worry about staying out of SPAM filters, unsubscribes, DKIM signatures, the list goes on and on.
Obviously there is a lot more to this than you realized. Good thing this problem has already been solved multiple times over.
Next, you say, “I’ll just let my users integrate their Mailchimp account.”
So you spend a few days slinging some code, and fully integrate the Mailchimp API. Your users now can send email newsletters to their customers with pretty templates and confidence that they’ll arrive. Life is good.
Then a support request comes in saying:
“Hey, I saw that you now enable integration with Mailchimp. This is so great! I’ve been sending customers emails since I signed up, but have to manually export them. Only problem is that I use Drip. How long before you offer an integration with them? Also, a good friend of mine is a user as well but uses Campaign Monitor, I know she’d love to be able to do the same. Hope to hear from you soon!”
You’re now stuck with dozens of support requests for integration with their favorite email app, or CRM. Plus, you have to worry about deprecations or changes to every API you’ve integrated with. ?
If only you could force them to integrate with your API. Those selfish developers should offer the ability to poll for changes and automatically update their records. After all, they’ve got millions in VC funding and a team of developers!
Cooler heads prevail, and you realize that it isn’t viable for anyone to keep up with every other app’s API who could potentially want to integrate.
? Then you remember webhooks!
Any time a change occurs in your own app, you can send an update via a webhook to any URL a user wants! Ingenious – let your users decide where and when to send data they want!
A few days go by and what once felt so overwhelming has now simplified into:
# customers_controller.rb def update if @customer.update_attributes customer_params current_user.webhooks.run "customer.updated", @customer redirect_to customer_path @customer else render :edit end end
Now anytime your user’s customers update a profile, they have instant push notifications to their favorite email app, CRM, and analytics tools!
Now you understand why I believe webhooks are the one feature you must add to your API.