# CallRail

CallRail is a call tracking and analytics platform that provides call recording, lead intelligence, and marketing attribution to optimize advertising campaigns.

## Overview

The CallRail platform builds on Call Tracking to provide an entire suite of integrated tools that makes marketing your business and turning leads into loyal customers a cinch. CallRail Call Tracking solution attributes (or matches) incoming phone calls and text messages to your marketing activities.

## \*\*API Information \*\*

The Base URL used for the CallRail connector is **<https://api.callrail.com>**. More information can be found on their main [API documentation](https://apidocs.callrail.com) site.

## Authentication

Within the builder, click on the CallRail connector to display the connector properties panel. Select the 'Auth' tab and click on the 'New authentication' button.
In the Tray.io authentication pop-up modal, name the authentication in a way that will quickly identify it within a potentially large list. For example, whether it is a Sandbox or Production auth, etc.
Consider who/ how many people will need access to this authentication when choosing where to create this authentication ('Personal' or 'Organisational').
![auth-callrail-page-1](https://tray.ai/documentation/images/connectors/service/callrail/7Ix1ufbi97sJCYpdyPEpb0_image.png)
The second page asks you for your '**API Key**' credentials.
![callrail-auth-2](https://tray.ai/documentation/images/connectors/service/callrail/5yqtHVpQmZfzMVuZTxpdS0_image.png)
To get this field, head to the CallRail dashboard. Click on the Integrations tab, navigate to API Keys from the left menu panel as shown in the below image or make sure you are logged in and then click on this [API Key](https://app.callrail.com/settings/a/170499692/settings/api-keys) link. It will lead you to the same page.

![callrail-dashboard](https://tray.ai/documentation/images/connectors/service/callrail/4HIBhsREZM3KvT0hWzAsgn_image.png)
Once you have added these fields to your Tray.io authentication pop-up window, click the 'Create authentication' button. 
Your connector authentication setup should now be complete.

## Available Operations

The examples below show one or two of the available connector operations in use.
Please see the [Full Operations Reference](#operationsFull) at the end of this page for details on all available operations for this connector.

## Using the Raw HTTP Request ('Universal Operation')

As of **version 1.0**, you can effectively create your own operations.
This is a powerful feature that you can use when there is an endpoint in CallRail that is not used by any of our operations.
To use this, you will first of all need to research the endpoint in the  [API documentation ](https://apidocs.callrail.com/)to **find the exact format** that CallRail will be expecting the endpoint to be passed in.
For example, say that the **'Listing All Conversations'** operation did not exist in our CallRail connector, and you wanted to use this endpoint. You would use the CallRail [API docs](https://apidocs.callrail.com/) to find the relevant endpoint - ***which in this case is a `GET` request called: `*****/v3/a/&#123;account_id&#125;/text-messages.json*****`.***`*** ***`
More details about this endpoint can be found [here](https://apidocs.callrail.com/#listing-all-conversations).
![sample-callrail-op-](https://tray.ai/documentation/images/connectors/service/callrail/1L1hoWMolZwYYacoZhQw1b_image.png)
Based on the information provided in the above API call doc, you need to configure the following attributes on your Tray platform:

* **Method:** GET
* \*\*URL: \*\*
  * \*\*Endpoint : \*\*/v3/a/{account\_id}/text-messages.json
    ![tray-paltform-get-example-callrail](https://tray.ai/documentation/images/connectors/service/callrail/4GsgQtrh4amP6OSk4B21hH_image.png)
    Once the API call is executed successfully,  you should get the following results:
    ![callrail-samle-op-output](https://tray.ai/documentation/images/connectors/service/callrail/2NfdPw0DfcnYKvFhOrkTyl_image.png)

## Example Usage

> **Info:** **TRAY POTENTIAL:** Tray is extremely flexible. By design there is no fixed way of working with it - you can pull whatever data you need from other services and work with it using our core and helper connectors.

Below is an example of a way in which you could potentially use the CallRail connector, to iterate through the Parameter formats stored within your Terminus app.
The steps will be as follows:

1. Setup using a manual trigger and List all accounts operations.
2. Add a Loop connector to iterate through the calls.
3. Get each account call's information details.
   Your completed workflow should look similar to this:
   ![example usage work flow example](https://tray.ai/documentation/images/connectors/service/callrail/50ckHuj169npXjMVZCVOJb_image.png)

### Step-by-step Explanation

### 1 - Setup Trigger & List accounts

With your trigger in place (be it [Manual](https://tray.ai/documentation/connectors/trigger/manual-trigger/), [Scheduled](https://tray.ai/documentation/connectors/trigger/scheduled-trigger/), [Callable](https://tray.ai/documentation/connectors/trigger/callable-trigger/) etc) add a CallRail connector. Set the operation to 'List all accounts'.
![callrail-step-1](https://tray.ai/documentation/images/connectors/service/callrail/Z7kYDdAbIjtlLvVl2H5xX_image.png)
Feel free to re-name your steps as you go along to make things clearer for yourself and other users. The operation names themselves often suffice.
When run, this workflow will list all the accounts  available within your CallRail account.

### 2 - Loop Collection

Next, search for the 'Loop collection' connector within your connector panel, and drag it into your workflow as your next step. Set your operations to 'Loop list'.
The Loop connector allows you to iterate through a list of results. In this example, we will use it to iterate through the data found within the previous CallRail connector step.
While hovering over the 'List' field in the 'List parameter formats' step (with the tail end of the connector-snake), select `accounts` from the list of output properties displayed. This will auto-populate a jsonpath within your list input field, and update the type selector to jsonpath.
For more clarification on the pathways you have available, open the Debug panel to view your step's Input and Output.

> **Info:** **JSONPATHS:** For more information on what jsonpaths are and how to use jsonpaths with Tray, please see our pages on [Basic data concepts](https://tray.ai/documentation/platform/automation-integration/building-workflows/mapping-data/basic-data-concepts) and [Mapping data between steps](https://tray.ai/documentation/platform/automation-integration/building-workflows/mapping-data/mapping-data-between-steps)

> **Info:** \*\*CONNECTOR-SNAKE: \*\*The simplest and easiest way to generate your jsonpaths is to use our feature called the [Connector-snake](https://tray.ai/documentation/platform/automation-integration/building-workflows/mapping-data/mapping-data-between-steps/#the-connector-snake). Please see the main page for more details.

![callrailstep2](https://tray.ai/documentation/images/connectors/service/callrail/2tNdJVHBqv8guLnY328uyi_image.png)
When run, this workflow will iterate through the list of accounts  provided be the earlier step.

### 3- Get calls of each account

The last step is to drag a CallRail connector **inside** the Boolean connector step itself. Set the operation to 'List all Calls'. As you can see, the 'Account ID'  is required.

> **Info:** \*\*INTERPOLATION: \*\*When you wish to include JSON generated data within another input/output result, use our Interpolation method as described [here](https://tray.ai/documentation/platform/automation-integration/building-workflows/mapping-data/mapping-data-between-steps#interpolated-mode).

![callrail 2 step](https://tray.ai/documentation/images/connectors/service/callrail/13zSx8VWkDFprm8ta46tyZ_image.png)
![output-callrail-](https://tray.ai/documentation/images/connectors/service/callrail/29wtnzQLpmGiO2eVx4bSQ8_image.png)
When run, the workflow will now iterate through the list of accounts  provided and get each account call details. See the Debug panel for more details.

> **Info:** \*\*BEST PRACTICES: \*\*Whenever you do decide to create your own workflow, be sure to check out some of our key articles such as:- [Using callable workflows](https://tray.ai/documentation/platform/automation-integration/building-workflows/composable-workflows/calling-other-workflows)
> - [Pagination](https://tray.ai/documentation/platform/automation-integration/advanced-use-cases/batching-queueing/pagination)
> - [Data transformation guide](https://tray.ai/documentation/platform/automation-integration/building-workflows/mapping-data/data-transformation-guide)
