Inside TFC: How We Connected ActBlue to Zapier
At TFC, we get a fair number of donations through ActBlue; in order to track donations and make sure we thank our donors in a timely fashion, we needed something better than manually pulling reports on an ad hoc basis.
This sounds like it shouldn’t be a big deal, but took a bit of investigation — typically, an engineer would have to set up a server with a publicly accessible endpoint. That endpoint would then forward data to relevant services. I’ll explain how we connected our ActBlue donations to our internal services without setting up a separate server.
If you work for a campaign or non-profit and rely on ActBlue, or just want a peek behind the scenes at TFC, read on.
Using Zapier to Automatically Capture ActBlue Donations
At TFC, we are heavy users of Zapier for automating workflows. Unfortunately, there is no pre-existing integration of ActBlue with Zapier. The good news is, ActBlue has support for webhook callbacks that trigger on every donation. This callback includes data about the the donor and the contribution made.
That’s where Zapier comes in, which has integrations with a multitude of APIs. Zapier instances (called “Zaps”) can be configured to receive a trigger (e.g. a Google Sheet is updated), followed by some set of actions (e.g. send a Slack message). One of the trigger options is an HTTP endpoint.
Combining these two services allowed us to ingest ActBlue data with no engineering overhead.
Now when we receive a new ActBlue donation, it’s pushed into a master database, the donor is added to the right email list, and an automatic Slack message is created to alert TFC staff to the donation. That saves us a lot of time, and makes it easier to thank donors for their support.
To achieve the above, you’ll do the following high level steps in Zapier:
- Create a new Zap that will set up a webhook endpoint — to provide a destination for ActBlue to push data.
- Validate basic authentication on that endpoint — to comply with ActBlue’s security requirements.
- JSON decode the response — to transform the webhook format into data friendly for Zapier
- Put the decoded data to work in the Zap.
Creating a New Webhook Endpoint
- Create a new Zap.
- Add a webhook trigger step to the Zap.
- Select “Catch Hook” as the webhook trigger type.
- Skip the “Pick off a Child Key” section.
- Copy the created webhook.
Validate Basic Authentication
- Paste the previously copied webhook URL in your ActBlue webhook callback URL.
- For basic authentication credentials, create a random username / password combination and input it into the auth section. Save this username / password for later.
- Enable ActBlue webhook to start hitting the endpoint.
Back in Zapier:
- Click “OK, I did this.”
- Add a filter step to the Zap.
- Select “Only continue if…” as the filter option.
- Set the match options to:
- “Header Http Authorization”
- “(Text) Exactly matches”
- “Basic CREDENTIALS”
Note: CREDENTIALS here is the username/password credentials from above that have been base64 encoded. To get the base64 encoded version of your credentials, simply do the following in your terminal (on *nix based systems such as OS X, or Bash CLIs like Cygwin on Windows):
echo -n username:password | base64
JSON Decode Response
Continue in Zapier:
- Add an action step.
- Select “Code” as the action type.
- Under input data, create a new variable named “blob” that’s value is the HTTP body from Step 1.
- Under code, input the following:
output = json.loads(input_data['blob'])
Put the Data to Work
That’s it! You can now use this data to send Slack messages, update Google Drive files, add data to your email database, or more just by adding additional action steps to the Zap and using the output from step 3 (the above “code” section).