Zapier

Zapier advanced integration manual

This article provides a step-by-step guide on how to send tree gifts through Tree-Nation's email system using Zapier, rather than your own email service.

 

Requirements: Tree-Nation Premium & Zapier

Integration difficulty: Easy, no coding skills required

Step 1: Request an API Token

To receive your token and installation instructions, please fill the form below and submit it. Your API-token will be sent via email soon after.

Step 2: Setup your Trigger


We will review a case below where we will offer a tree to every person added into our Zoho CRM.

  1. Start by creating a zap trigger. To do that, go to your Zapier Homepage and at the top left corner click on create Zaps.



  2. Click on the Trigger button to select the app that will perform the trigger. In our case example, It is HubSpot.



  3. On the setup tab, select the App and its trigger that will offer a tree to your recipient, and connect your account. In the case below, we have used Zoho app to offer trees to every new contact.




  4. On the test tab, test the trigger to obtain a list of records that will be used as examples to visualise their properties. 

Note the properties displayed that contains the information of the name of the recipient and his email address. You will use these fields later.

 

Step 3: Setup your Action

 

  1. Add an action step on the Zapier Zap and choose Code





  2. On the setup tab, set the Action event to "Run Javascript"



  3. On the configure tab, set the following parameters:
    1. Input data:
      1. Write "name" at the first field, then click on [+] on the right side and search for the full name and click it
      2. Add value set, write "email" at the second field, then click on [+] on the right side and search for the email of the tree-gift recipient and click it

    2. Code: Copy the code below and paste it in the code field of your zap configuration, and add your token (i.e. 123456abcdef) in the second line as shown below


const url = "https://tree-nation.com/api/plant";
const token = "YOUR_BEARER_TOKEN_HERE"; // Replace with your actual Bearer token received through email

const name = inputData.name;
const email = inputData.email;

const data = {
 recipients: [
  {
   name: name,
   email: email
  }
 ]
};

fetch(url, {
 method: "POST",
 headers: {
  "Content-Type": "application/json",
  "Authorization": `Bearer ${token}`
 },
 body: JSON.stringify(data)
})
  .then(response => response.json())  // Parse JSON response
  .then(responseData => {

    callback(null, { success: true, response: responseData });
  })
  .catch((error) => {

    callback(error);
  });

You should now be able to test your integration. Complete your test and publish your zap to automate your planting habit with Tree-Nation.