Outbound SMS referencing event source data?

We are using SMS Interactions in Journey Builder and for a particular use case i need to reference the value of a field tied to the event source data. The field originates from Salesforce, and as such is called Event:Id

I’ve tried simply referencing it with the following, as I would with emails – but this doesn’t work. Any ideas?

%%[
VAR @EventId
SET @EventId = Event:Id
]%%

Salesforce support has come back saying the SMS interactions in journey builder doesn’t treat event data the same way, but that there might be a lookup via Mobile Number that could be possible.

Anybody got any ideas?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Unfortunately you can’t pass Attributes from an Event Source Data Extension to Send SMS Activities, this only works in email activities which is frustrating.

There’s also no great way to map the ContactKey to the mobile subscriber; both the _Subscribers and _MobileAddress Data Views have ContactId, but these only match if you create the Contact at the same time using the REST API.

The issue is that you really only have mobile number and any releated mobile demographic attributes. One solution that I can think of is to:

  1. Add a new field to your Mobile Demographics Attribute Set (in the MobileConnect Data Attribute Group) named ‘ContactKey’
  2. Create a query where you can pass the Contact Id of the Sales Cloud record to a Data Extension, along with Mobile Number and Locale
  3. Set an import Activity to import your mobile subscribers from the DE created in step 2 to the ‘All Contacts – Mobile’ List (I assume you are doing this already to get the Contacts as MobileConnect contacts)
  4. Map the Contact Id value from Sales Cloud to the Contact Key while setting up your Import Definition
  5. Create an Automation with an Import Mobile Contacts Activity to import the contacts
  6. Use the following code in your SMS message:
%%[
var @contactKey, @eventIdRows, @eventRow, @rowCount, @eventId
set @contactKey = AttributeValue('ContactKey')
set @eventIdRows = RetrieveSalesforceObjects("Events","Id","WhoId", "=", @contactKey)
set @rowCount = rowcount(@eventIdRows)
if @rowCount > 0 then
    set @eventRow = Row(@eventIdRows, 1)
    set @eventId = field(@eventRow, "Id")
endif
]%%Event ID is: %%=v(@eventId)=%%

If anyone has any better ideas, I’d be keen to hear of them!

/* Revising Eliots answer with the final solution */

Given the nature of the event object (or child objects in particular), we ran the risk of there being multiple meetings, future and past, so we could do the simple lookup that Eliot mentioned below here – we needed to reference the exact record that entered the journey.

Now this was feasible because it was trigger based communications, in a way. The SMS was being initiated by a checkbox being set on events inside Core Salesforce, and that was controlled using time-based workflows. The minute that checkbox was set, we had a green light to send the sms.

Therefore the journey design was:

  • Step 0: Make sure contacts are imported with the custom attribute as per Elliots guidance.
  • First Journey Activity: Stamp Event ID onto Contact Record in Salesforce (custom field)
  • Then send sms based on below code

What that allowed for was the code below, which was inspired by / made possible with elliot’s help.

%%[
VAR @EventId, @Location, @SystemEventDate, @TimeAdjustment, @EventDate, @StartDate, @StartTime, @OwnerId, @OwnerName, @OwnerMobile, @ContactRows, @ContactRow, @RowCount, @ContactKey

SET @ContactKey = AttributeValue("SFID")
SET @ContactRows = RetrieveSalesforceObjects("Contact","Latest_MC_SMS_EventId__c","Id", "=", @contactKey)
SET @RowCount = RowCount(@ContactRows)

IF @RowCount > 0 then
    set @ContactRow = Row(@ContactRows, 1)
    set @EventId = field(@ContactRow, "Latest_MC_SMS_EventId__c")

    IF Length(@EventId) > 0 THEN

        SET @EventDE = "ent.Event_Salesforce"
        SET @UserDE = "ent.User_Salesforce"

        SET @EventRows = LookupRows(@EventDE, "Id", @EventId)
        IF RowCount(@EventRows) > 0 THEN
            SET @Event = Row(@EventRows, 1)

            SET @Location = Field(@Event, "Location")
            SET @SystemEventDate = Field(@Event, "StartDateTime")
            SET @TimeAdjustment = Lookup("Time_Offset", "Adjustment", "Locale", "DK")
            SET @EventDate = DateAdd(@SystemEventDate, @TimeAdjustment, "H")
                SET @WeekDay = FormatDate(@EventDate, "ddddd", "", "da")
                SET @StartDate = FormatDate(@EventDate, "dd/MM-YY", "")
                SET @StartTime = FormatDate(@EventDate, "", "HH:MM")

            SET @OwnerId = Field(@Event, "OwnerId")
                SET @OwnerName = Lookup(@UserDE, "Name", "Id", @OwnerId)
                SET @OwnerMobile = Lookup(@UserDE, "MobilePhone", "Id", @OwnerId)
        ENDIF
    ENDIF     
ENDIF
]%%
Your meeting will be held as agreed on %%=v(@WeekDay)=%%, %%=v(@StartDate)=%% at %%=v(@StartTime)=%% on%%=v(@Location)=%%. If there are changes please call 
%%=v(@OwnerName)=%% on phone number %%=v(@OwnerMobile)=%%


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x