0

Thanks for taking the time! We are facing an issue today with our SMS. We have a journey that sends several SMS messages, we capture the responses, integrate them into a Data Extension, and then ask another question.

Here is an example with the first 3 SMS messages:

  1. An SMS that sends a question from a journey (outbound SMS from Journey Builder) (WITH NEXTKEYWORD : RESPONSEDAY01)

  2. An SMS text response that captures the answer to question 1. and asks a follow-up question (keyword for this SMS: RESPONSEDAY01). it redirect to RESPONSEDAY02 with the function CreateSMSConversation('XXXXX', MOBILE_NUMBER, 'RESPONSEDAY01','MOBILECONNECT')

  3. An SMS text response that captures the answer to question 2. and sends a thank you message (keyword for this SMS: RESPONSEDAY02).

If the text is not a number between 0 and 10, we need to ask the user to re-enter their response.

The issue : it's sends an error SMS "Keyword was not define" when we enter "ten" so not a numeric messages, after the first message.

Here is the AMP script for the TEXT response message related to The REPONSEDAY01 keyword :

var @response, @isValid, @errorMessage, @message
set @response = [MSG(0).NOUNS]
if trim(RegExMatch(trim(concat(" ", @response)), '([0-9]+)', 1)) != "" and @response >= 0 and @response <= 10 then
    set @isValid = "true"
else
    set @isValid = "false"
    set @errorMessage = "Invalid response. Please reply with a number between 0 and 10."
ENDIF
if @isValid == "true" then
    UpsertData('XXXXXXXXXXXX', 1, 'Phone', MOBILE_NUMBER, 'ResponseDay0-1', @response)
    set @message = 'Thank you. How would you rate your sleep loss in the last 7 days? 0 is not sleep loss, 10 did not sleep at all.'
    CreateSMSConversation('XXXXXX', MOBILE_NUMBER, 'RESPONSEDAY02','MOBILECONNECT')
ELSE
    set @message = @errorMessage
UpsertData('XXXXXXXXXXXX', 1, 'Phone', MOBILE_NUMBER, 'ResponseDay0-1', @response)
     CreateSMSConversation('XXXXXX', MOBILE_NUMBER, 'RESPONSEDAY01','MOBILECONNECT')
endif
]%%```



Here is the AMP script for the TEXT response message related to The REPONSEDAY02 keyword :



``` %%[
var @response, @isValid, @errorMessage, @message
set @response = [MSG(0).NOUNS]
if trim(RegExMatch(trim(concat(" ", @response)), '([0-9]+)', 1)) != "" and @response >= 0 and @response <= 10 then
    set @isValid = "true"
else
    set @isValid = "false"
    set @errorMessage = "Invalid response. Please reply with a number between 0 and 10."
ENDIF
if @isValid == "true" then
    UpsertData('XXXXXXXXX', 1, 'Phone', MOBILE_NUMBER, 'ResponseDay0-2', @response)
    set @message = 'Thank you'
ELSE
    set @message = @errorMessage
UpsertData('XXXXXXXX', 1, 'Phone', MOBILE_NUMBER,'ResponseDay0-2', @response)
CreateSMSConversation('XXXXXX', MOBILE_NUMBER, 'RESPONSEDAY02', 'MOBILECONNECT')
endif
]%% ```

Thank you so much ! 

0

You must log in to answer this question.

Browse other questions tagged .