We're trying to achieve the following workflow with AMPscript and MobileConnect and was wondering if someone could assist.
1. Send an Outbound message (using the Fuel REST MessageContactSend method) with a next keyword to link to a Text Response template.
2. Use a Text Response template (using the next keyword from the Outbound message) that includes AMPScript MSG(0) and NOUN(0) function to check the MO message for the presence of a string and sends a reply based on whether or not the string is present:
%%[ Var @msg
if (Uppercase([MSG(0).NOUN(0)]) == "yes") then
Set @msg = "Thank you for consenting to receive messages."
else
Set @msg = "Invalid response"
endif ]%%
%%= v(@msg) =%%
3. Use the MSG(O1) function (in the Text Response template) to insert a record into a Data Extension with the response:
%%[
SET @message = v([msg(0).nouns])
InsertData("Messages", "message", @message)
]%%
This is working fine, but the issue that we are having is that while we can insert the MO response and even the mobile_number
into the Data Extension, we cannot seem to insert _subscriberkey
. Essentially what I want to achieve is to track individual MO responses to the outbound message. The issue is that mobile_number
may not always be unique. That is, if a mobile subscriber receives more than one message, I wan't to identify to which message they are replying to.
I'd also be OK if we could retrieve the original Outbound message using AMPscript, as I can use this to reconcile which message they are replying to.
I note that I can use the getQueueMOHistory API method to retrieve the complete history of the (a) outbound message, (b) the MO Response, and (c) the Text Response:
{
"count": 3,
"createDate": "2015-07-19T14:35:35.51",
"status": "Active",
"history": [
{
"type": "MT",
"message": "Would you like to receive communications from us?",
"date": "2015-07-19T14:35:35.51"
},
{
"type": "MO",
"message": "yes",
"date": "2015-07-19T14:36:36.04"
},
{
"type": "MT",
"message": "Thank you for consenting to receive messages",
"date": "2015-07-19T14:37:03.88"
}
]
}
So there's obviously a trackable chain here, but is it possible to insert a unique identifier (tokenId
from the MessageContactSend method, _subscriberkey
or other identifier) using AMPscript into a Data Extension, so I can achieve a similar tracking function?