AMPscript Functions for Mobile Messages
Use these functions with mobile messages that you send using MobileConnect. These functions return values that only apply to mobile messages. You can’t use these functions in email messages, landing pages, or other content types.
Msg(0)
The Msg() function returns the entire content of a mobile-originated (MO) message. A mobile-originated message is a message sent from the mobile device of a subscriber to your SMS phone number. Compare MO messages to mobile-terminated (MT) messages, which are messages that you send to a subscriber’s mobile device.
The function only accepts a value of
0
as its parameter.Verb
The Verb helper function, used together with
Msg(0)
, returns the keyword from an MO message. The function doesn’t accept any arguments. It can only retrieve the current keyword specified in MobileConnect. For example, if the keyword is “OFFER” and the MO message is “OFFER 2065550042”, then the functionMsg(0).Verb
returns a value of “OFFER”.Nouns
The Nouns helper function, used together with
Msg(0)
, returns all of the message content that follows the keyword. For example, if the keyword is “OFFER” and the MO message is “OFFER John Smith”, then the functionMsg(0).Nouns
returns a value of “John Smith”.Noun()
The Noun() helper function, used together with
Msg(0)
, returns a specific word in a mobile message. This function requires you to pass a parameter that indicates the position of the word in the message. A value of0
indicates the first word in a message after the keyword, a value of1
indicates the next word in a message, and so on. For example,Msg(0).Noun(1)
returns the second word in the message after the keyword.- MMS_Content_URL()
The MMS_Content_URL() function returns the URL of incoming MMS content used in a mobile message. This function works only with MobileConnect accounts when sending MMS messages. You must retrieve and store this data within your own system for later usage. For example, you can send the URL to another program that distributes the content residing at the URL to another person for review. We recommend that you use this feature with an approval filter in Media Share and Media Response message templates to prevent unauthorized content from reaching your contacts.
This function requires you to provide the ordinal of the MMS content contained in the MO MMS message. A value of
0
indicates the MMS content in the current MO message.
These examples illustrate common use cases for mobile-specific functions in SMS messages.
This example checks the MO message for the presence of a specific word.
If the MO message contains the specified word, the value of the @msg
variable contains a string that provides additional information. If the MO message contains a different word, then the variable contains a string that tells the subscriber that they provided the wrong keyword.
In the Media Share template, enter an outbound response.
The outbound message takes the URL of the MMS content from the incoming MO message. You can then take the URL and forward it to another source, such as an external site or an RSS feed.
In addition to these mobile-specific functions, you can also use the InsertData() and DeleteData() functions in MobileConnect messages.