# Automation Script

Create documents automatically using Airtable Automations.

{% embed url="<https://youtu.be/xhg7RK9LuPg>" %}

## Setup

{% stepper %}
{% step %}

### Add your Airtable PAT key to Documint

First, add your Airtable PAT key to connect your Documint account to Airtable. Follow this short video to get that set up.

{% embed url="<https://www.youtube.com/watch?v=2IQr70weNYg>" %}
{% endstep %}

{% step %}

### **Connect the template with your database**

In the template builder, select the Airtable to connection you made by adding the PAT key, pick the base, and the table you'd like to integrate with Documint.

<figure><img src="https://1903534506-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTY5wPd81K7B5rjyG5tjS%2Fuploads%2FkQASu4A5ifaQs8Pp1gGr%2Fconnect%20at.gif?alt=media&#x26;token=4de510df-20e1-4e5c-bd1f-0479576e6047" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Create the Script

Hop over to the Integrations. tab and go for the Airtable option in the setup section

<figure><img src="https://1903534506-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTY5wPd81K7B5rjyG5tjS%2Fuploads%2Fesr4Otn491Qo5Z9cngYW%2FScreenshot%202026-03-10%20at%2015.41.47.png?alt=media&#x26;token=ad818578-33f8-47de-a1f3-9de97bf05c5f" alt=""><figcaption></figcaption></figure>

In the table you have integrated the template with, add an attachment field to store the created document.

<figure><img src="https://1903534506-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTY5wPd81K7B5rjyG5tjS%2Fuploads%2FetTWzlkFgSoZXW4J1ebY%2FScreenshot%202026-03-10%20at%2015.49.03.png?alt=media&#x26;token=bf606870-f628-4b4c-b529-912a9f9f8b02" alt=""><figcaption></figcaption></figure>

Go to the Automation Script tab, select the attachment field from the dropdown, and the Script will show up for you to copy.

<figure><img src="https://1903534506-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTY5wPd81K7B5rjyG5tjS%2Fuploads%2Fx2yW24eX41qeOhbfs0XC%2FScreenshot%202026-03-10%20at%2015.44.27.png?alt=media&#x26;token=17139ce6-48ed-4edf-a335-7027207ea7e4" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Create the Automation

Switch back to Airtable and open the Automations panel

<figure><img src="https://1903534506-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTY5wPd81K7B5rjyG5tjS%2Fuploads%2Fk2ZfzQ7COy3PxVm9aldP%2FScreenshot%202026-03-10%20at%2015.51.28.png?alt=media&#x26;token=0fc6684a-9a93-4793-98ef-89069464f8de" alt=""><figcaption></figcaption></figure>

Create a new automation and add your trigger. This can be any trigger that you'd like.

<figure><img src="https://1903534506-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTY5wPd81K7B5rjyG5tjS%2Fuploads%2FoN3Zrng04yayDdUimqdq%2FScreenshot%202026-03-10%20at%2015.54.02.png?alt=media&#x26;token=e184d68e-4a04-4301-9361-222df8e65bb6" alt=""><figcaption></figcaption></figure>

Configure your trigger.

<figure><img src="https://1903534506-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTY5wPd81K7B5rjyG5tjS%2Fuploads%2FbHlg9PeYowRENMKujgCn%2FScreenshot%202026-03-10%20at%2015.58.47.png?alt=media&#x26;token=0dc2fe09-92fe-4dc7-a032-4365a80cd31b" alt=""><figcaption></figcaption></figure>

Add an action and select 'Run script'

<figure><img src="https://1903534506-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTY5wPd81K7B5rjyG5tjS%2Fuploads%2Fke8ibR1OkTKUZ9XH9lR4%2FScreenshot%202026-03-10%20at%2016.00.44.png?alt=media&#x26;token=77af36dd-fdc8-4bbf-bc9c-68d00c9e8cf0" alt=""><figcaption></figcaption></figure>

Paste your script

![](https://1903534506-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTY5wPd81K7B5rjyG5tjS%2Fuploads%2FqQqxP8YjThka1t6gucS2%2FStep%2011.png?alt=media\&token=8e68302a-9716-45c7-aed9-50a5c79f7419)

Add an input variable named `record_id` and set the value to the `Record ID`

![](https://1903534506-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTY5wPd81K7B5rjyG5tjS%2Fuploads%2F6nxIZUEpaTsNVcEkQxVY%2FStep%2012.png?alt=media\&token=9e846b28-4587-4969-84bf-63950d46bce6)

Test your script and click `Finish editing`

![](https://1903534506-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTY5wPd81K7B5rjyG5tjS%2Fuploads%2FJDmcxApAxoH9n4QbiZVN%2FStep%2013.png?alt=media\&token=92fde7d5-6402-413f-9bf4-949f9480d0fa)
{% endstep %}
{% endstepper %}
