# Automation Script

Create documents automatically using Airtable Automations.

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

## Setup

{% stepper %}
{% step %}

### Connecting Documint and Airtable

First, connect your Documint account to Airtable. Follow this article to get that set up.

{% content-ref url="/pages/cmA1vQNIzcbRkp2Ai6ls" %}
[Connecting your Documint account with Airtable](/integrations/airtable/connecting-your-documint-account-with-airtable.md)
{% endcontent-ref %}
{% endstep %}

{% step %}

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

In the template builder, select the Airtable connection you made, pick the base, and the table you'd like to integrate with Documint. Then, continue to select the fields you'd like to use on your template.&#x20;

<figure><img src="/files/sDdaWAhFm9haeXKILY6g" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Create the Script

Under Sources, in the Airtable connection, click on "Add formula" and select the "Automation script" option.&#x20;

<figure><img src="/files/cP1DXgCHsqh6LNdMCQro" 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="/files/OVXXEehEMCbtXItJyJcA" 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="/files/XnP1PYmtbHaukSLGH4tO" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Create the Automation

Switch back to Airtable and open the Automations panel

<figure><img src="/files/5GL6vtR2Qeb0UyuGg2JI" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/7y0b4pGtqM7HjWYnfzat" alt=""><figcaption></figcaption></figure>

Configure your trigger.

<figure><img src="/files/uv4tICJuXvAeRl4G9Be1" alt=""><figcaption></figcaption></figure>

Add an action and select 'Run script'

<figure><img src="/files/wh8MqSqkfbrh8kEToseL" alt=""><figcaption></figcaption></figure>

Paste your script

![](/files/ZEe3MYRCigxnRg3sbWFN)

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

![](/files/mh8N3ql1jqDga1LCo7nK)

Test your script and click `Finish editing`

![](/files/YTYBXsx5OD4mDsnrn4f9)
{% endstep %}
{% endstepper %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.documint.me/integrations/airtable/automation-script.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
