Typeform -- how to parse "other" answers

I am using n8n cloud and building an automated workflow that pulls Typeform responses into AirTable. I am encountering an issue when trying to parse single select answers that provide an “other” response. If a user selects one of the pre-provided options within typeform, then the value is passed straight to airtable, however if the user selects ‘other’ and then types a response, then an object is returned containing both the key “other” and the value “whatever the user wrote”

From an airtable perspective, responses in column 1 are populating a single select and can therefore only deal with pre-provided responses or the word ‘other’, a second column then has a free text option to capture the user response (if provided).

The issue i encounter is that I am using “set” node to assign a typeform value to an airtable column, which works fine unless a user selects ‘other’ since this returns an object.

So my question is this…is there an easy method of parsing the data into different columns based on whether a value or object is returned? Or is there another method that I should use?

The logic required is something along the lines of IF Key is “other” then column 1 is “other” and column 2 is “free text” (first response in below screenshot), ELSE use ‘label’ value in column 1 (response 2 in below screenshot). Should I use a function to select the right part of the answer or is this handled by an if statement? I am a bit of newb with this!

Hi @thebaobabnetwork, welcome to the community!

I think this kind of filtering would require a bit of code (might also be possible with JMESPath, though I have not used this myself). I am happy to try and find something suitable though, would you be able to share the full JSON output from your Typeform Trigger node for both cases (one example if anything but other is selected and one example for other)?

Cheers!

Thanks!

This is the JSON returned, I have toggled “simplify answers” to off in the Typeform Trigger node:

Result 1: User selects one of the pre-provided options:
{
“type”: “choice”,
“choice”: {
“label”: “Google”
},
“field”: {
“id”: “hHCXIz3j4FoL”,
“type”: “multiple_choice”,
“ref”: “01G2PPZE6DSXYVZ7JREPYP8SRB”
}
}

Result 2: User selects “Other” and provides a free-text response
{
“type”: “choice”,
“choice”: {
“other”: “Other provided answer”
},
“field”: {
“id”: “qrHogCDCLYZA”,
“type”: “multiple_choice”,
“ref”: “9f03b7a8-b8ee-46bd-a6c2-5889c722cc94”
}
}

Perhaps a slightly separate issue, but I have also noticed this morning that if I don’t have the “simplify answers” toggle set to “off” the results from the typeform trigger node sometimes ignore or don’t pull through any “other” free text answers.

Hey, did you manage to get anywhere with this? Just checking in because I have had absolutely no luck.

Sorry @thebaobabnetwork, I was out of office half of last week and wasn’t quite sure what to make of your data which is why I only looked at it now in more detail.

The data you have shared didn’t seem to be the full JSON data processed by n8n, so I need to reproduce this myself first to get an understanding of how Typeform data is structured. Unfortunately, I ran out of the included free submissions before I could look at all possible data structures Typeform submits.

So based on the snippets you have shared and on what I’ve seen during my limited tests I assume your full JSON data looks something like this:

[
    [
        {
            "type": "choice",
            "choice": {
                "label": "Google"
            },
            "field": {
                "id": "hHCXIz3j4FoL",
                "type": "multiple_choice",
                "ref": "01G2PPZE6DSXYVZ7JREPYP8SRB"
            }
        }
    ]
]

While your examples do show different id values I assume that’s because they are from two different questions questions and not because they actually change between responses, is that correct?

If so, we could use the id field to identify the data we want (this is assuming your form has multiple questions). Unfortunately, n8n does not have built-in features for the transformation you have in mind, so we’d need to write this ourselves.

Here’s an example using a Function Item node. It first searches for the field with the given id, then returns the content of the label field if available, else the content of the other field in a new answer field:

Hope this helps!