How do I insert dynamc values in templates?

I need to add dynamic values, e.g. {{params.cost}} and dynamic link to buttons, e.g. {{params.link}}, on templates. I can’t figure out how to add those dynamic values in templates. « Add variable » tool icon doesn’t work for me. I don’t want the values from the contact info and external source. I will pass them ithrough API.

Hello and Welcome @net100 :slightly_smiling_face:

Here is an example transactional email

API: https://developers.brevo.com/reference/sendtransacemail

Example of sending via Php/curl

data « params » allows you to customize the content of the email

<?php
//Send a transactional email

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.brevo.com/v3/smtp/email");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  "accept: application/json",
  "content-type:application/json;charset=utf-8",
  "api-key: myHappyKey"
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$datas ='

{
  "sender": {
   "email": "contact@siteweb.com",
   "name": "Philip Dupont "
  },
  "params": {
    "first_name": '.json_encode($first_name).',
    "titre": '.json_encode($titre).',
    "description": '.json_encode($descriptionemail).',
    "heure": "'.$jour.'",
     "ticket": "'.$ticket.'",
    "materiel": '.json_encode($materiel).',
    "url": "'.$url.'",
    "id": "'.$id_reunion.'",
    "code": "'.$code.'"
  },
  "to": [
    {
      "email": "'.$email.'",
      "name": '.json_encode($nom_complet).'
    }
  ],
  "subject": "Welcome | siteweb.com",
  "templateId": 76
 
}
';
curl_setopt($ch, CURLOPT_POSTFIELDS, $datas);
$response = curl_exec($ch);
    
      if (curl_errno($ch)) {
      echo curl_error($ch);
      die();
    }
curl_close($ch);

I hope this was useful to you :wink:

1 Like

Thanks for the reply!

My problem was that when I type in {{params.link}}, it was not converted to the variable somehow. I tried it again after my post, and it worked. :sweat_smile: So I am all set.

1 Like