Using Google Civic API & GravityFlow Outgoing Webhook

I’ve always wanted to use an API and intergrate it with WordPress. It’s a silly thing to want to do but if you use WP extensively you understand what you can accomplish with a few plugins and some elbow grease. As such I recently was discussing an issue a client was facing, how to retrive municipal data set of represntatives via an address submission or lookup.








This in itself is not new, you can visit the following.

Representitive/Legislative Search Websites

Who Represents Me Uses Open State API
My Reps Uses Google Civic API
Who are my representatives? Uses Google Civics API & Open Secrets. (Also my favorite)
Common Cause Uses Google Civic API, Opem States and ProPublica.

But the question was how to do this with WordPress, surely there must be a plugin available somewhere in the repository. The answer would be yes.. and no.

Searching I found three plugins that seemed to be the answer, kind of.

WordPress Representative/Legislative Search Plugins:

CongressLookup by Constructive Growth LLC
Find Your Reps by Kathleen Malone
WP Legisearch by Dan Roberts

Out of the three only CongressLookup worked well. Find Your Reps was a bit finicky and Legisearch was a cool idea but the author of that plagin hasn’t updated it in years.

The problem my client faced was little more nuanced, they use gravity forms and the data had to be filtered into a user submitted form and searchable on the frontend! So CongressLookup plugin wasn’t going to cut it.

I’ve never used WP to either POST or GET anything API but a little more research and I found what I was looking for. GravityFlow, I’m an actual subscriber to the service but never looked into any Webhook/API related documentation. A quick check revealed the Outgoing Webhook option.

The idea that you could map responses to field values was mind blowing. See below (from


Image from GravityFlow

I wanted to create a polling locator for NYC so voters could find the closet one by searching an address.

With the plugin already installed the first thing to do is get a Google Civics API key by logging into you Google account and navigate to the developers portal here. Sign up for the key and go through the rigamarole. Test the key in your browser using the following link (add your api key at the end) YOUR KEY HERE

Now see if you get the following back from the api:

Now to create the GF form that I’ll use. First we’ll create an address field that will be used for search for the polling locations. Then we’ll create the form fields that we’ll match to the key meta.


And we want to make sure we use the GET method when calling the Google Civics API

Your going to hide all those fields but use the Gravity Forms All Fields Template to output into a page or post.

A few Political APIs

A great place to test your API is ReqBin which has a few tools you can use sending a GET request to the REST API endpoint.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts