3

I have a list of contacts from the Sales Cloud that I have imported into a MobileConnect list. I stored the Id of a Person Account record from Sales Cloud as the "Contact Key". Here's the CSV file that I have used to import the contact into the MobileConnect list.

_MobileNumber,_LastName,_FirstName,_Email,_CountryCode,_ContactKey 91990007913,Smith,Jane,jane@smith.com.au,AU,0019000003edTguAAE

I mapped the _ContactKey column to the "Contact Key" field on the MobileConnect list. The contact was imported and I can see that the Id from the Person Account record of the Sales Cloud is now the Contact Key in the Marketing Cloud.

I have set up a campaign whereupon receiving a keyword from the subscriber, I want to update a specific field in the Sales Cloud Contact record.

I have used the following lines of code in my Text Response message associated with the keyword. From the various articles and stackexchange questions and answers, I gather that the Contact Key is the SubscriberKey

Outbound Response Code

Here's the text representation of the code. I couldn't get the formatting right. When I try sending an Outbound message and responding with the TESTBED keyword, all I get in response is "There was an error processing your message.". I'm not sure what I am doing wrong. Any help would be much appreciated.

%%[ 
var @response, @contactId, @subscriberKey, @result 

if trim(uppercase([MSG(0).NOUN(0)])) == "TESTBED" 
    set @contactId = Lookup("_MobileAddress","_ContactID","_MobileNumber",mobile_number) 

    set @subscriberKey = Lookup("_Subscribers","SubscriberKey","SubscriberID",@contactId) 

    set @result = UpdateSingleSalesforceObject("Account",@subscriberKey,"Opt_Out__c","true") 

    set @response = CONCAT("TESTBED message received. Thank you.", " Opt Out Result is ", @result) 
else 
    set @response = "Sorry, we did not recognise your response." 
]%% 

%%=v(@response)=%%
2

After speaking with Marketing Cloud support, I was advised to store the Salesforce Id for a Contact or Account in a custom field (SF_ID of type text) in the Mobile Demographics. New field in the mobile demographics using the data designer

I was able to make use of the _MobileAddress data view to get the value from the SF_ID custom field. Also, while importing contacts in MobileConnect, I had to map the Salesforce Id field to the SF_ID custom field.

Here's the final code that worked for me:

%%[
var @response, @contactId, @subscriberKey, @result 

if trim(uppercase([MSG(0).VERB])) == "TESTBED" then
    set @subscriberKey = Lookup("_MobileAddress","SF_ID","_MobileNumber",MOBILE_NUMBER)
    set @response = CONCAT("Message received. You have been opted out.)
    set @result = UpdateSingleSalesforceObject("Account",@subscriberKey,"Opt_Out__c","true")
else
    set @response = CONCAT("Sorry, we did not recognise your response.", " NOUN value is: ", uppercase([MSG(0).VERB]))
endif
]%%

%%=v(@response)=%%

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.