Hi everyone!
I’m building an AI Agent in n8n that creates records in Airtable via a Tool node. My table has three field types I’m struggling with:
-
Single Select — the field doesn’t offer “Defined automatically by the model” option, only fx expression mode. What’s the correct way to let the AI fill this field?
-
Linked Record — I understand Airtable requires a record ID array. Is the only way to handle this a two-step approach: first Search the linked table to get the ID, then Create the record? Or is there a cleaner solution?
-
Multi Select — similar to Single Select but expecting an array. Is {{ [$fromAI('field', '', 'string')] }} the right pattern?
Any working examples or templates would be hugely appreciated!
I think that the best approach for Single Select would be to use something like the “fx” expression with $fromAI() with all of the potential options for the Single Select field so for example {{$fromAI(‘status’, ‘One of: Active, Inactive, Pending’, ‘string’)}}. This will have to be done for all so that the AI can decide what to do.
Though for the Linked record you will need to pass in the ID with the two-step approach {{ [$fromAI(‘linked_id’, ‘Record ID from the linked table’, ‘string’)]}}. The Airtable API requires the record ID, not a name/label.
For the multi select field we need to make sure that $fromAI returns a comma, separated string and not a single string by default. You will need to split these values. An example of this, {{ $fromAI(‘tags’, ‘Comma-separated values, e.g. Tag1, Tag2’, ‘string’).split(‘,’)}}
This way n8n knows how to parse the incoming formats for Airtable and knows that it must pick from an exact list and not create guesses.
Thank you so much for your reply. I tried the from AI with the status but it says that string is not a valid type
Interesting it could be because either n8n or Airtable was not expecting a type parameter to be passed along, n8n may already infer the type you are trying to pass along to. Perhaps try removing the type parameter entirely, try something like this
{{ $fromAI(‘status’, ‘One of: Active, Inactive, Pending’) }}