šŸ”„ Google Sheets integration is live! Learn more

How To Import Data into Airtable When a Record is Updated

Aug 9, 2022ā€¢Rosie Threlfall

In this easy-to-follow guide, we'll use Data Fetcher and theĀ exchangerate.hostĀ API to import current currency exchange rates into Airtable whenever a change is made to a record in Airtable. We will also schedule the exchange rates to update on a regular schedule so we always have access to the latest figures.

We'll import currency data when a record is updated, but you can use the same approach to import stock prices, crypto prices, enrich leads or any other information.

This tutorial is 100% no code and Data Fetcher's standard features are free to use.Ā 

What is exchangerate.host?

Exchange rates API is aĀ free service offering easy access to current and historical foreign exchange rates & crypto exchange rates.

Create Rates Table

Create a new table in your Airtable base called 'Rates'. Add a Single select field with the name 'Currency'.

Currency1.png

Add the names of any currencies you wish to convert into the 'Currency' field. This needs to be the standard currency abbreviation, e.g. BRL, GBP, EUR & CAD.

exchangerate15.png

Install Data Fetcher

Next, add Data Fetcher to your base from the Airtable marketplace.Ā This free extension enables you to import many different types of data into Airtable.

After you have added the Data Fetcher to your Airtable base, you'll need to either create a free Data Fetcher account. You can also sign in to your existing account using the 'Have an account?' button on the bottom left of the Data Fetcher screen.

You can also sign-up to Data Fetcher with your Google account by selecting 'Continue with Google'.Ā 

Data Fetcher Sign Up

Create Request to Import Exchange Rate into Airtable

Select 'Create your first request' from the Data Fetcher home screen. Data Fetcher requests are used to import and export data. You can create multiple saved requests within one installation of Data Fetcher in an Airtable base.

Create your first request in Data Fetcher

On the create request screen, select 'exchangerate.host' for Application.

exchangerate3.png

For Endpoint choose 'Convert from one currency to another'.

exchangerate4-endpoint.png

Give your request a name such as 'Import currency data' and click 'Save & Continue'.

exchangerate5.png

Add a reference to your output table by clicking on the + button on the right-hand side of the From currency field and selecting your 'Rates' table and 'Currency' field.

Click 'Confirm'.

exchangerate6.png


For To currency select the currency you wish to convert into. For this example, we are using USD.

exchangerate7.png

exchangerate8.png

TheĀ Response field mappingĀ modal will now open. This is how you configure how the fields from exchangerate.host will map to fields in your output table.Ā 

For each imported field, you can either map it to an existing field in your output table or create a new one. You can also set the field type for each new field.

Click filter all to remove any pre-selected fields, then use theĀ Find fieldĀ search bar to easily locate the fields you want to import.

For this example, we are going to import the Rate field and map this to a new field with type Currency.

exchangerate9.png

You will now see a new field in your output table called 'Rate' which has been populated with the exchange rates in USD for the specified currencies.

exchangerate16.png

Import Data into Airtable When a Record is Updated

In order to run this request and import data when a record updated, we'll need to create an automation in Airtable and use Data Fetcher webhooks.Ā 

Webhooks are a paid Data Fetcher feature, so you will need to upgrade your account. To do this, in Data Fetcher, scroll to Schedule and click 'Upgrade'.

schedule-requests.png

Select a plan from the options and enter your payment details to upgrade.

data fetcher upgrade options

Return to Data Fetcher and click 'I've done this'.

schedule-upgrade.png

Click 'Add API key' and copy and paste your Airtable API key. You can find your Airtable API key here.

Group 11(1).png

Enter your Airtable API key and click 'Save'.

save-airtable-api-key.png

UnderĀ Webhook, click 'Turn on webhook for request' and copy the URL to your clipboard.

exchangerate10-webhook.png

Next, click onĀ Automations at the top of the Airtable screen and then select 'When a record is updated'.

exchangerate20.png

Under CONFIGURATION select your 'rates' table.

exchangerate12.png

And a reference to your 'Currency field' under 'Fields'.

exchangerate19.png

Then select 'Run script' from the Run actions menu.

exchangerate21.png

Then paste the webhook into the Edit Script window.

Enrich-New-Leads13.png

Copy this script:

await fetch(`YOUR_WEBHOOK_URL?record_id=${input.config().record_id}`)

And paste it above the webhook in the script window in Airtable.

Enrich-New-Leads17.png

Next, replace YOUR_WEBHOOK_URL with your webhook URL.

Enrich-New-Leads18.png

We now want to replace input.config().record_id with the Record Id from the trigger of the form being submitted.

Enrich-New-Leads20.png

Click on + Add input variable.

Enrich-New-Leads21.png

Add record_id into the Name box.

Enrich-New-Leads22.png

Then under Value choose 'Airtable record ID'.

exchangerate12.png

Click 'Test' in order to Test output.

Enrich-New-Leads25.png

You should now see 'Test ran successfully'.

Enrich-New-Leads26.png

Next, turn on your Automation.

exchangerate14.png

You'll now see that if you add (or edit) a record in your 'Currency' field, the figure in the 'Rate' field will be automatically updated to the current exchange rate for USD.

exchangerate17.png

Schedule Exchange Rates to Update Automatically

We can also set the 'Rate' field to update on a schedule in order to keep the exchange rates current by using Data Fetcher's scheduling feature.

Under Schedule toggle 'Schedule this request'.

Group 1(12).png

You can select a schedule based on intervals of 'Minutes', 'Hours', 'Days' or 'Months'. As exchange rates are updated daily we will choose to run the request once a day. Click 'Save', and current exchange rates will automatically import into your Airtable base on a daily basis.

exchangerate18.png

Related Posts

How to Enrich New Leads from a Contact Form in Airtable

How to Enrich New Leads from a Contact Form in Airtable

Jul 28, 2022

ā€¢

Rosie Threlfall

ā€¢ClearbitWebhook
Import Historical Exchange Rates in Airtable

Import Historical Exchange Rates in Airtable

Feb 20, 2022

ā€¢

Andy Cloke

ā€¢FinanceCurrency Conversion
How to Convert Currency in Airtable

How to Convert Currency in Airtable

Jul 29, 2021

ā€¢

Andy Cloke

ā€¢FinanceCurrency Conversion