Trigger survey based on date provided by participant | XM Community
Skip to main content

Hi there,
I'm conducting a longitudinal survey where a participant will complete questionnaires at 5 timepoints. I've linked all the surveys together with embedded data.
When the participant completes the first survey, their contact details and relevant embedded data are populated into XM Directory. Normally I would then create a workflow to schedule the next survey to be distributed to the respondent x days later, however this won't quite work for what I want to do.
Participants are sent a link by their GP practice to take part in the survey - this is approximately one week before they are due to have an appointment with their doctor. As part of this survey, they're asked to provide the date of their upcoming GP appointment (this is done as a text response/content validation question and entered as dd/mm/yyyy).
I need for the second survey to be distributed 7 days after the date respondents give in the survey. I've set that response to be an embedded data field within the contact list in XM Directory, but then I'm not sure how to take it from there, if it's possible?
If not, does anyone know if there are any workarounds rather than manually setting a schedule based on respondent responses?
Thanks in advance :)

Hello RachDH
Yes, there is a way! Not straightforward but with a custom code.
Step1: Get the dates in one format (ISO 8601 ), your respondent might be typing it in mm/dd/yyyy you can convert the same via Javascript. You should consider using moment.js. Load moment.js in the survey header, then it can be used to parse and format the date. You can also add or subtract the number of days dynamically via custom code.
e.g.: var SENDDATE= moment("${q://QID3/ChoiceTextEntryValue}").toISOString();
Step2: Once you have the dates converted push them back in embedded data to store them for each respondent.
e.g.: Qualtrics.SurveyEngine.setEmbeddedData( 'DATE', 'SENDDATE' );
Step3: Create a Workflow after the response is recorded with an API task to send email distribution. Pipe the embedded data DATE in the place of sendDate.
This will automate the process for you!

Hope this helps!






Hello RachDH
Yes, there is a way! Not straightforward but with a custom code.
Step1: Get the dates in one format (ISO 8601 ), your respondent might be typing it in mm/dd/yyyy you can convert the same via Javascript. You should consider using moment.js. Load moment.js in the survey header, then it can be used to parse and format the date. You can also add or subtract the number of days dynamically via custom code.
e.g.: var SENDDATE= moment("${q://QID3/ChoiceTextEntryValue}").toISOString();
Step2: Once you have the dates converted push them back in embedded data to store them for each respondent.
e.g.: Qualtrics.SurveyEngine.setEmbeddedData( 'DATE', 'SENDDATE' );
Step3: Create a Workflow after the response is recorded with an API task to send email distribution. Pipe the embedded data DATE in the place of sendDate.
This will automate the process for you!

Hope this helps!




 

Hi There, 

 

Sorry to come to this thread after two years but it came up in my search. Is there a way to achieve this without API integration?

 

Thanks.


No, it’s still the way to go.


Hello, 

Back again sorry, if anyone is able to help. I have set up the workflow with an API task, it is working in both the test in the WebService bit of the workflow, and in the run history of the workflow. However, email that is meant to be sent is not coming through (I have checked spam).

When I go to my Data & Analysis tab for the first survey, the correct adjusted date is displayed and the email address is there. The email address has also been added to the mailing list in the directory the API task refers to.

I’ve put the cURL request below incase it is of relevance, although as I say this is testing fine. 

The only issue I have found is in Directory, under Distributions, it is displaying 2 emails failed. So I think I am missing something but I am unclear what, and would very much appreciate some pointers.

Thanks!

curl -XPOST -H 'X-API-TOKEN: <REDACTED>' -H 'Content-Type: application/json' https://<redacted>.qualtrics.com/API/v3/distributions -d '{
"message": {
"libraryId": "<REDACTED>",
"messageId": "<REDACTED>"
},
"recipients": {
"mailingListId": "<REDACTED>",
"directoryId": "<REDACTED>"
},
"header": {
"fromName": "Qualtrics",
"replyToEmail": "noreply@qualtrics.com",
"fromEmail": "noreply@qualtrics.com",
"subject": "Survey Distribution"
},
"surveyLink": {
"surveyId": "<REDACTED>",
"expirationDate": "2028-12-31T00:00:00Z",
"type": "Individual"
},
"sendDate": "${e://Field/adjustedDate}"
}'

 


Leave a Reply