Artisan IMG > Coda (coda) (6a11b1b9-df94-455a-9b3b-381beed9bb3c)

Coda
1.0

Coda is a new doc that brings words, data, and teams together.

Overview
Copy

Coda blends the flexibility of a document, the power of a spreadsheet, and the utility of applications into a single new canvas, enabling teams to work with data and words, in a more collaborative, dynamic, powerful and intuitive way than possible with traditional documents or spreadsheets.

Authentication
Copy

When using the Coda connector, the first thing you will need to do is go to your Tray.io account page, and select the workflow you wish to work on. Once in the workflow builder itself, search and drag the Coda connector from the connectors panel (on the left hand side) onto your workflow.

With the new Coda connector step highlighted, in the properties panel on the right, click on 'New Authentication' which is located under the 'Settings' heading.

This will result in a Tray.io authentication pop-up window. The first page will ask you to name your authentication, and state which type of authentication you wish to create ('Personal' or 'Organisational').

As you can see, the next page asks you for your 'API token' credentials.

In order to get these fields, first head to your Coda login page and login.

After logging in, click on the icon/button in the upper right corner of the page, then on the three-dot menu button and select 'Account settings'.

This will take you to your 'Account settings page'. Scroll down on this page until you reach the 'API settings' section and click the 'Generate API token' button.

Give your token a name (required). You can also add 'Read/Write' restrictions to specific docs if needed (optional). When you have entered a name for your token (and set any optional restrictions, if needed), click the 'Generate API token' button.

You will now be able to copy your token, by clicking 'Copy token'.

PLEASE NOTE: You will not be able to copy your token later, so please make sure you do so now, before leaving, or refreshing this page.

Once you have added these fields to your Tray.io authentication popup window, click on the 'Create authentication' button. Go back to your settings authentication field (within the workflow builder properties panel), and select the recently added authentication from the dropdown options now available.

Your connector authentication setup should now be complete.

Available Operations
Copy

The examples below show one or two of the available connector operations in use.

Please see the Full Operations Reference at the end of this page for details on all available operations for this connector.

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

As of version 1.0, you can effectively create your own operations.

This is a very powerful feature which you can put to use when there is an endpoint in Coda's API, which is not used by any of our operations.

To use this you will first of all need to research the endpoint in the Coda REST API: Record API (Beta) v1, to

find the exact format

that Coda will be expecting the endpoint to be passed in.

Note that you will only need to add the suffix to the endpoint, as the base URL will be automatically set (the base URL is picked up from the value you entered when you created your authentication).

The base URL for Coda is: https://coda.io/apis/v1

For example, say that the 'List docs' operation did not exist in our Coda connector, and you wanted to use this endpoint, you would use the Coda API docs to find the relevant endpoint - which in this case is a GET request called: /docs.

More details can be found here.

As you can see there is also the option to include a query parameter, should you wish to do so. So if you know what your method, endpoint and details of your query parameters are, you can get information about docs that are accessible by you with the following settings:

Method: GET

Endpoint: /docs

Query Parameter: Key: limit Value: 10

Body Type: None

Final Example outcome being: https://coda.io/apis/v1/docs?limit=10

Example usage
Copy

TRAY POTENTIAL: Tray.io 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. This demo which follows shows only one possible way of working with Tray.io and the Coda connector. Once you've finished working through this example please see our Introduction to working with data and jsonpaths page and Data Guide for more details.

Below is an example of a way in which you could potentially use the Coda connector to list all the rows in all tables, within a doc.

The steps will be as follows:

  1. Setup using a manual trigger and list the tables in a specific Coda doc.

  2. Add Loop collection step to iterate through each table found within the doc.

  3. List all the rows for each table within the specific Coda doc.

The final outcome should look like this:

1 - Setup Trigger & list tables
Copy

Once you have clicked 'Create new workflow' from your main Tray.io dashboard named it, select the Manual trigger from the trigger options available:

After you have been redirected to the Tray.io workflow dashboard, from the connectors panel on the left, add a coda connector to your second step. Set the operation to 'List tables' and either select a doc from the dropdown menu in the 'Doc ID' field (Demo Table doc, in this example - a previously created doc that contains 1 table), or enter a valid doc ID in the 'Doc ID' field.

Please feel free to re-name your steps (perhaps after their operational names, as in the demo) as you go along, to make things clearer for yourself and other users.

When run, the workflow will list the tables contained within the doc specified in the 'Doc ID' field.

2 - Loop Collection
Copy

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 Collection 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 Coda connector step.

In order to specify the list you want to loop through, start by using the 'List' mapping icon (found next to the list input field, within the properties panel) to generate the connector-snake.

While hovering over the 'List records' step (with the tail end of the connector-snake), select items from the list of output properties displayed. This will auto-populate a jsonpath within your 'List' input field ($.steps.coda-1.items, in this example), 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.

JSONPATHS: For more information on what jsonpaths are and how to use jsonpaths with Tray, please see our pages on Basic data concepts and Mapping data between steps

CONNECTOR-SNAKE: The simplest and easiest way to generate your jsonpaths is to use our feature called the Connector-snake. Please see the main page for more details.

When run, the workflow will list the tables contained within the doc specified in the 'Doc ID' field and then simply iterate over each table in the returned list.

3 - List rows
Copy

The last step is to drag a final Coda connector inside of the actual Loop Collection step itself. Set the operation to 'List rows'. As you can see, the 'Doc ID' and 'Table ID or name' fields are required.

After selecting or entering the same 'Doc ID' as in step 1 of this example (Demo Table doc, in this example). Use the connector-snake method for auto-generating the jsonpath for the 'Table ID or name' ($.steps.loop-1.value.id, in this example). This time drag your mouse over the previous loop step and select id from within the value. This is exemplified in the image below:

When run, the workflow will now list the tables contained within the doc specified in the 'Doc ID' field, iterate over each table in the returned list and list all the rows (and their contents) contained within each table.

The inputs & outputs of each step of the workflow is displayed within your Debug panel.