JSON Event API - Phone numbers | XM Community
Skip to main content

Hello,
I've created a survey workflow that is triggered by an API call from our case management system (CMS). It works fine for email distributions, but not mobile. I think the problem is that CMS sends out the phone data out in a format that does not include the US country-code as the prefix: 1-XXX-XXX-XXXX.
Is there a way to reformat the phone number within the JSON Event task of the workflow so that it includes the US country code prefix?
Thanks for any suggestions.

Hi ebclc,
You are probably right, Qualtrics is really strict on requiring country code in front of a mobile number.
If you're wanting to handle this on Qualtrics's side, you could add a Code task to grab the phone number from the JSON, add a 1 in front of it and then send it down to the rest of the workflow.
Good luck!


Thanks bgooldfed! Yes this looks like what I need to do. I had a go but I'm new to this and think there's an error in my code below - any ideas? Thanks for any help you can offer.
---
function codeTask() {

let us_country_code = "1-";
var phone = us_country_code.concat("", phone)

             return {
                          result: phone
             }
}


https://community.qualtrics.com/XMcommunity/discussion/comment/48907#Comment_48907It looks like you're not bringing in the phone variable correctly. It's in a JSON from the API call made by the CMS right?
You can pipe in data from webservices like so:
image.pngWhich will display everything fetched from the JSON (this is a random example from a workflow I had set up in the past):
image.pngStore that in a variable and then you should be able to contact it with the country code. The rest of your code looks fine.
PS: I don't think you need to append the "-" to the number for Qualtrics to send mobile texts. I've always managed to just use the full number eg: 1555555555


Thanks very much bgooldfed, that worked! For anyone who needs to see the solution, here's what worked for me.
I added a CodeTask step after my JSON event. This takes the original "phone" value from the API call and formats it to include a "1-" in front.
function codeTask() {
let text1 = "1-";
let text2 = "~{aed://phone}";
let text3 = text1.concat("",text2);
return {
formatted_phone: text3
}
}
Then, in my next workflow step (XM Directory), I have the value for "Phone" piped in from the preceding task result, i.e. "formatted_phone".


https://community.qualtrics.com/XMcommunity/discussion/comment/49032#Comment_49032Well done, glad it is working 🙂 If my comment solved the issue, please accept it as the answer.
Cheers!


Thanks bgooldfed. I think I've accepted the answer now!


Leave a Reply