Written by lily on December 7, 2016

Lily is a very open system. Using APIs she can handshake and exchange information with any other system.

To show the power of APIs we built some integrations over the last few weeks. WordPress is the most popular tool to build websites. It’s the default for over 20% of websites around the world. Websites often have contact forms so customers can easily contact an organisation. If you use a CRM system, filling in data from that email into a CRM is redundant work. That’s why we decided to automate it.

We used Gravity forms to build the contact forms. Gravity can be hooked up to Zapier which we use as a man in the middle to do the translation from the form data and automatically create an account, contact and deal in Lily.

Step 1: Get the URL for Gravity forms from Zapier

Go to Zapier and create a new Zap which starts with Gravity forms. The wizard will supply you with a Zapier URL that has the following format: https://hooks.zapier.com/hooks/catch/uniquevalue/. Copy this URL.


Step 2: Insert the Zapier URL in Gravity forms

Download and install the Gravity Forms Zapier add on. Go to Gravity forms in your WordPress environment and insert the Zapier webhook URL.

Step 3: Push the Gravity form data to Lily and create an account

The next step is to fill in the form and send test data to Zapier. In Zapier you can now add a next step which is a Webhook of the type Custom Request.

We will first create an account, and the Webhook variables you need to give are:

  • Method: POST
  • URL: https://app.hellolily.com/api/accounts/
  • Data Pass-Through: no
  • Data:
  • Unflatten:no
  • Headers:
    • Content-Type: application/json
    • Authorization: Token APITOKEN
    • Cache-Control: no-cache

The STATUS ID can be found by looking at the source of a deal you edit as exampled below.

The API TOKEN can be found in Lily on the Preferences page

The USERID can be found by going to https://app.hellolily.com/api/users/me/ with the user you want to assign the account to.

Step 4: Create a contact

Creating a contact is a repetition of Step 3. A few parameters change:

  • URL: https://app.hellolily.com/api/contacts/
  • Data:
    {"salutation":1,"gender":2,"first_name":"FIRST NAME","last_name":"LAST NAME","email_addresses":[{"is_primary":true,"status":2,"email_address":"EMAILADDRESS],"phone_numbers":[],"addresses":[],"tags":[{"name":"autocreated"}],"accounts":[ACCOUNTID],"social_media":[]}

In this example we tag the contact with autocreated, just as we did with the account. Of course you can use any tag here. The ACCOUNTID is data you get back from your previous step.

Step 5: Create a deal

Creating a deal is a repetition of Step 3 again. This time these parameters change:

  • URL: https://app.hellolily.com/api/deals/
  • Data:
    {"new_business":true,"tags":[{"name":"autocreated"}] ,"currency":"EUR","amount_once":"0","amount_recurring":"0","account":ACCOUNTID,"contact": CONTACTID, "found_through":FOUNDTHROUGHID,"contacted_by":CONTACTEDBYID ,"why_customer":WHYCUSTOMERID ,"name":"Quote for CONTACTNAME from ACCOUNTNAME ","status":STATUSID,"next_step":NEXT_STEPID,"next_step_date":"DATE"}

FOUNDTHROUGHID, CONTACTEDBYID, WHYCUSTOMERID, NEXT_STEPID and STATUSID are all found by looking at the source code like we did for the STATUSID in step 3. For DATE we performed some trickery.

If you leave the deal unassigned it will automatically appear in the ‘unassigned deals’ widget on your Lily dashboard!

Handy Zapier and API testing things

Zapier filter

Zapier has filters. You can use these to stop certain actions if for example you miss some data. Mind you: it’s not an If/Else kind of filter. It’s If only.

Zapier formatter

Zapier has a formatter. You can use this to format your data. If you have a full name field for example you can use the formatter to split that data into what likely will be a first and a last name. We also use the formatter to add a ‘day after tomorrow’ date to the deal form which is used as the next step date on creating a deal.

PATCH instead of POST

Sometimes you want to update certain data. You can use a PATCH instead of a POST. The webhook variables will change:

  • Method: PATCH
  • URL: https://app.hellolily.com/api/contacts/CONTACTID/

Use fake data

It is sometimes useful to use fake data for mandatory fields which you can later update if you find out you have the right information in a quote form. For example: if a contact name field is not mandatory your Zap will fail when you try to create a contact. It is easier to create the contact using temporary data and update it via a PATCH if the information is present.

Example ZAP flow

We use all of the above to optimize the quality of the data put in Lily. An example of our flow:

  • Remove the returns from the textfield the client filled in -> Formatter, text
  • Remove the new lines from the textfield the client filled in -> Formatter, text
  • Create an account -> webhook, POST
  • Create a contact with fake first/lastname data (because it is one field) -> webhook, POST
  • Update the deal followup date -> formatter, date/time
  • Create a deal -> webhook, POST
  • Check if a contact name is present -> Filter and if so
  • Separate the contact name field into the likely first name -> Formatter, text
  • Separate the contact name field into the likely last name -> Formatter, text
  • Rename the contact -> webhook, PATCH

Using Postman

A final thing we struggled with is the lack of feedback you get from Zapier when you fire JSON to Lily and Lily says no. The Chrome plugin Postman really helped out here. You can fire your JSON using the right headers directly at Lily and you’ll get more feedback. If you want to get started with Postman their documentation and ‘getting started’ video is really helpful.

Leave a Response

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