0

I have an Outbound SMS message and a Text response message setup. These work as planned based on the Next Keyword 'INFO'

When a customer replies with this keyword i want to save their information along with the keyword into a data extension.

Below is my message and code but it does not work. Am quite new to MobileConnect.

Outbound message (Am passing 3 x attributes here)

Congrats. Text 'INFO' to 4984

%%[

set @id = AttributeValue('Id')
set @email = AttributeValue('Email')
set @phone = AttributeValue('Phone')

]%% 

Text response

%%[
set @number = MOBILE_NUMBER
set @orderedRows = LookupOrderedRows('Rahul', 0, 'Id DESC, Email ASC', 'Mobile', @number)
IF [MSG(0).VERB] == "INFO" THEN
set @id = Field(Row(@orderedRows, 1), 'Id')
set @email = Field(Row(@orderedRows, 1), 'Email')
InsertData('Customer_response', 'Id', @id, 'Email', @email, 'Mobile', @number, 'Response', [MSG(0).VERB])
endif
]%%

1 Answer 1

1
  1. Change your function to UpsertData, UpsertDE only works in emails: Capture Mobile Number of Customer who Reply STOP

  2. Debug that with hardcoded values instead of variables to eliminate errors in empty vars, the function or the matching to the data extension.

  3. If it works with hardcoded data, start making the variables @id , @email, @phone dynamic again one by one, to see if your RequestParameter functions work - to be honest, I wouldn't be surprised if the vars are plain empty as it is.

One simple thing is, you can simply use MOBILE_NUMBER as @phone, and lookup the other data by that:

Here is a nice strategy to do it, i.e. logging the mobile number, email and id already in the outbound message, together with a static "magic word". In the 2nd SMS, look that Data Extension up by "mobile number + magic word" Using AttributeValue function with SMS send inside a journey builder and you can keep using the same data throughout the conversation.

Limitation is: If you use the same mobile number for multiple IDs, this could confuse them.

======

In your edit, you ask about an if statement containing the keyword INFO not working.

Short answer: that's a "Verb", not a "Noun".

Long answer: MobileConnect structures SMS into "Nouns" and "Verbs".

A "Verb" is a keyword that is sent in a message coming in through Mobile Connect. What comes after the Keyword are the "Nouns".

Keywords are not case sensitive (OFFER is the same as offer), neither is AMPScript.

Sample response:

OFFER my name is Peter

[MSG(0)] is the entire message:

OFFER my name is Peter

[MSG(0).VERB] returns the verb:

OFFER

[MSG(0).NOUNS] returns everything BUT the Verb:

my name is Peter

[MSG(0).NOUN(n)] returns the nth Noun aus, starting to count at 0:

my

Your message ("INFO") has no nouns. It only has a verb. Change your if statement to use the verb:

IF [MSG(0).VERB] == "INFO" THEN


/* proceed */

END
3
  • Thank you for the suggestion Jonas. InsertData works but only with hard coded values and not RequestParameter so i may have to do an orderlookuprows to call the values from the DE. That is part 1. Next will be to make the IF and THEN work. I will revert with the correct code when i have it working.
    – Rahul G
    Nov 17, 2021 at 1:47
  • So i am able to call the values without the IF statement but not with the IF statement. I want to call the values when the keyword INFO is texted. I have inserted the amended code under text response. any suggestions on how to make the keyword IF statement work?
    – Rahul G
    Nov 19, 2021 at 2:48
  • edited my answer. Nov 19, 2021 at 7:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.