Webhook campaign action: send array values

My idea is: send array of values during webhook send action in campaign editor. I’m trying to send a whatsapp message using a webhook and meta api. this is the curl to send:

curl -i -X POST `
  https://graph.facebook.com/v15.0/XXXXXXXXXXXXXX/messages `
  -H 'Authorization: Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' `
  -H 'Content-Type: application/json' `
  -d '{ \"messaging_product\": \"whatsapp\", \"to\": \"WHATSAPP-DEST-NUMBER\", \"type\": \"template\", \"template\": { \"name\": \"hello_world\", \"language\": { \"code\": \"en_US\" } } }'

but the template array cannot be sent because at the moment we can only send text values. In the example we can only send messaging_product, to and type.

template array contains a text value “name” and another array “language” but all the template array is sent as a text value

"messaging_product": "whatsapp",
"to": "WHATSAPP-DEST-NUMBER",
"type": "template",
"template":
	{
		"name": "hello_world",
		"language": {
			"code": "en_US"
		}
	}

I think these groups of people would benefit from this idea: everyone

Why I think they would benefit from this idea: because at the moment it is not possible

Any code or resources to support this idea: the UI maybe could be done in 2 ways:

  • using horizontal draggable items (at the moment there is only vertical draggable items to sort data values)
  • adding a select field next to each data field where select text/array value. in this case we should find a way to tell mautic when to “stop” the array indentation (we can use 3 values text, array start, array end)

the php code maybe it is quite simple, while cycling the data added to the webhook payload in this way:

if datatype==“text” write data as a text elseif datatype==“array start” we create an array and start to add into the array all the next values until we find an “array end” datatype

I would like to contribute with this idea by suggesting a more flexible (and maybe easier to implement) solution,

right now the webhook action has the feature to add content to the body payload in a pair of key/value:

my proposal is to leave a text area so you can write the entire body payload, using the tokens you seem fit,
like the image below: