How to access specific Facebook Ads API action_type values?

Hello everyone!

I'm trying to save Facebook Ads API data in my database, specifically the values from the "actions" array. The challenge is that the action_types can come in any order.

Here's an example of the API response:

{
  "actions": [
    {
      "action_type": "page_view",
      "value": "123"
    },
    {
      "action_type": "purchase",
      "value": "45"
    },
    {
      "action_type": "initiate_checkout",
      "value": "67"
    }
  ]
}

I tried to use this expression to save to the database but got an error:

{{actions[?(@.action_type=='page_view')].value || 0}}

image

Error message:
"Lexer Error: Unexpected token "@" at column 10 in expression"

What's the best way to:

Find specific action_type values ​​regardless of their position in the array
Save these values ​​in my database columns

I need to get:

page_view value
purchase value
initiate_checkout value

Any help would be highly appreciated!

Thanks in advance!

I know you know this @Apple lol

You're the 2nd person asking me for help this week haha, did I become famous in some local community?

Unfortunately, I lack the time to give a decent reply.

That expression you made, I don't know how you came up with it, it's very bizarre, you can forget it.

All I know is you might want to use the formatter .where, the exact UI steps I'd need to research and I lack the time, sorry

1 Like

@Apple You're famous man hahaha

Can you help me here? @Teodor @George @patrick