# Connect answr with Zapier

[Zapier](https://zapier.com/app/dashboard) is **an automation platform that connects your work apps and does repetitive tasks for you**. Zapier automates your work by connecting your apps and then moving information between them based on rules you set. Zapier connects 5,000+ of the most popular work apps.

{% hint style="warning" %}
Before using this guide, an account in Zapier must be created. If you don't have an account, just [register](https://zapier.com/sign-up/) to the platform. If you already have an account, just log in.
{% endhint %}

## Create a new Zap

After you are logged in to your Zapier account, click on the "+Create Zap". You will be redirected to the step by step no code wizard. Initially setup a trigger, that will initiate your zap. In our example the zap is triggered each time there is a new row in a table in a connected PostgreSQL database. Depending on your application, instead of this app, you can use an ERP/CRM (e.g. Pipedrive, Zoho, Asana, etc).

<figure><img src="https://2993576723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaeFFaXxEeZmdbsofIXux%2Fuploads%2FpBDUR9FU80KYVbfNxkpI%2Fimage.png?alt=media&#x26;token=08049509-060d-4e39-a737-3a08591a7f37" alt=""><figcaption><p>Setup a trigger</p></figcaption></figure>

{% hint style="info" %}
To configure a PostgreSQL server in Zapier just place the host IP/URL, credential and schema and you are ready to go. More details can be found [here](https://zapier.com/apps/postgresql/help).
{% endhint %}

## Setup login request with Zapier Webhooks

From the list choose the "Webhooks by Zapier" and event as **POST**. Click Continue to setup the action.

<figure><img src="https://2993576723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaeFFaXxEeZmdbsofIXux%2Fuploads%2F5N8TB0QBbofZYf794U0f%2Fimage.png?alt=media&#x26;token=88632bf0-89b4-4821-a6ac-4ced0fcc816c" alt=""><figcaption><p>Choose app and event</p></figcaption></figure>

From the wizard in the Set up action, paste the URL login endpoint.

{% code overflow="wrap" lineNumbers="true" %}

```url
https://api.answr.space/api:auth/auth/login
```

{% endcode %}

Add your credential in the Data section as shown in the figure below.

<figure><img src="https://2993576723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaeFFaXxEeZmdbsofIXux%2Fuploads%2FtmrhQ3qUjIVtrsvys06P%2Fimage%20(7).png?alt=media&#x26;token=6e21f0ae-1bb4-43b5-9f3a-45f767aee238" alt=""><figcaption><p>Setup the answr authentication call</p></figcaption></figure>

Now test the action to validate that the POST request was properly setup.

<figure><img src="https://2993576723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaeFFaXxEeZmdbsofIXux%2Fuploads%2FNjePIPeNDsaY4JIp81wZ%2Fimage.png?alt=media&#x26;token=8ff06d83-769e-4eb4-bcbe-5c46ebbcfb5b" alt=""><figcaption><p>Testing the answr authentication call</p></figcaption></figure>

## Setup the Climatic Variables with Zapier Webhooks

Add a second Webhook step, right after the previous one. Select which climatic or other data API endpoint you would like to integrate and paste its URL in the corresponding section. Select the **GET** method.&#x20;

<figure><img src="https://2993576723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaeFFaXxEeZmdbsofIXux%2Fuploads%2FPLqo2Xn7pbHpfrA5pNP9%2Fimage.png?alt=media&#x26;token=96ef34a2-35f9-4a85-8f4d-99d3f8c7599f" alt=""><figcaption><p>Choose app and event</p></figcaption></figure>

Then add one header item as shown in the figure below. It contains the authToken variable generated from the previous step. In the "Query String Params" section add an item with the following:

* Name: Input\_point
* Value: {"type":"point","data":{"lng":**LONGITUDE**,"lat":**LATITUDE**}}
  * The **LONGITUDE** and **LATITUDE** should be replaced by the coordinates of the location you request. These can either be hardcoded (as the figure below) or passed as variables from previous steps.

{% hint style="info" %}
Make sure you select "json" in the "JSON key" to return the results as a json structure
{% endhint %}

<figure><img src="https://2993576723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaeFFaXxEeZmdbsofIXux%2Fuploads%2FjZQ2u9lf3yFiz4bfmJuR%2Fimage.png?alt=media&#x26;token=dcd10cfa-b862-47ae-8259-20bf5acb7bc6" alt=""><figcaption><p>Setup the answr data API call</p></figcaption></figure>

Finally, test the action to validate that the input for the GET request was correct. Now you can use the response of the answr API to any of the supported Zapier applications!

<figure><img src="https://2993576723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaeFFaXxEeZmdbsofIXux%2Fuploads%2FOZO4NwQIzvef4aMaiLRk%2Fimage.png?alt=media&#x26;token=6f056aae-abc2-4d36-8d34-19d52d00144c" alt=""><figcaption><p>Successful answr API response</p></figcaption></figure>
