Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Customizing the email in the "mail_registered_participants" API request

  • Situr19
  • Situr19's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 months 3 weeks ago #253007 by Situr19
Please help us help you and fill where relevant:
Your LimeSurvey version: Version 6.3.8+231204 
Own server or LimeSurvey hosting: University server
Survey theme/template:
==================
(Write here your question/remark)
Hello, I would like to know if it's possible to format the content of the invitation email in the API request "mail_registered_participants" that I want to send to participants in my survey. Currently, I can send a generic invitation email using the API, but I would like to make it more specific. Since it's a longitudinal study, my goal is to create a script that updates the participant list and automatically sends invitation emails. What is the name of the parameter I should provide for this? Unfortunately, I've searched a lot and don't know how to do it.Thank you very much for your help.

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 months 3 weeks ago #253025 by DenisChenu
What do you mean by "more specific"

You can use (for example) attributes in email templates, then adapt text according to such attribute.
 

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.

Please Log in to join the conversation.

  • Situr19
  • Situr19's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 months 3 weeks ago #253041 by Situr19
Thank you, Denis, for the response.
I mean that I want to personalize my invitation email with a message addressed to the respondents, including explanations on how to complete the survey.
Here is the script I use to automate the sending of invitation emails.
I use RStudio with the "httr" package.      # Paramètre des conditions
overrideAllConditions <- list('tid = 4130')

# Construire la requête pour appeler la fonction mail_registered_participants
mailParticipantsRequest <- POST(
  rpcEndpoint,
  body = list(
    method = "mail_registered_participants",
    params = list(
      sSessionKey = key,
      iSurveyID = IDTokenORIG,
      overrideAllConditions = overrideAllConditions
    ),
    id = 1
  ),
  encode = "json"
)

# Exécuter la requête et obtenir la réponse
mailParticipantsResponse <- content(mailParticipantsRequest)

# Vérifier la réponse et traiter les résultats
if (!is.null(mailParticipantsResponse$error) && length(mailParticipantsResponse$error) > 0) {
  print(paste("Erreur lors de l'envoi des e-mails aux participants enregistrés :", mailParticipantsResponse$error[1]))
} else {
  print("E-mails envoyés avec succès aux participants enregistrés.")
  print("Informations sur l'action :")
  print(mailParticipantsResponse$result)
}

Thank you for the time you dedicate to addressing my issue
 

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 months 2 weeks ago #253075 by DenisChenu
I think you can't updateb the content of the email when using API.

BUT : using attribute
Code:
{if(TOKEN::ATTRIBUTE_2 =="M","Bonjour Monsieur,")}{if(TOKEN::ATTRIBUTE_2 =="F","Bonjour Madame,")}{if(TOKEN::ATTRIBUTE_2 =="","Bonjour,")}

Or directly
Code:
<p>{TOKEN::ATTRIBUTE_2}</p>
<p>{TOKEN::ATTRIBUTE_3}</p>
<p>{TOKEN::ATTRIBUTE_4}</p>
<p>{TOKEN::ATTRIBUTE_5}</p>
Where the sentence are in the attribute

attribute can be set in api.limesurvey.org/classes/remotecontrol...hod_add_participants

or updated in api.limesurvey.org/classes/remotecontrol...rticipant_properties

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.

Please Log in to join the conversation.

  • Situr19
  • Situr19's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 months 2 weeks ago #253233 by Situr19
Hello Denis,
I finally figured out what wasn't working. In fact, I wasn't using the right query, so the email I was sending was the notification to the administrator used for survey follow-up reminders to the administrator (query: mail_registered_participants). Whereas, in fact, I needed the "invite_participants" query, which allowed me to automate the sending of the email I had already prepared on the LimeSurvey platform and which included the use of "attributes." Anyway, I just wanted to thank you for taking the time to respond to me.

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose