0

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?

1
  • I do have a solution for you but I really need to test it first. Please give me 36 hours to come back to you on this one! Apr 26, 2017 at 0:18

1 Answer 1

2

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)=%%
6
  • Hey Eliot ! Thanks for this! It makes sense - and especially in cases where the SubscriberKey != SalesforceId (it does in this case). The challenge here is that 1 contact can have 20+ events over time, and we always need to fetch the correct one. Based on ContactKey, I would in theory be able to created something like: %%[ SET @Rows = LOOKUPORDEREDROWS('ent.Event_Salesforce',1, desc 'LastModifiedDate,'WhoId', @ContactKey) ]%% (does this make sense to you? (this wont work if it has to be a live sms due to sync delays i know) Apr 27, 2017 at 7:20
  • Another method.. come to think of it... would be to have a field in salesforce that filters on, which is set to null by the journey after sending the SMS.. something like: set @ eventIdRows = RetrieveSalesforceObjects("Events","Id","WhoId", "=", @ contactKey, "Field", "=", "FilterValue") This might work... thanks Eliot! I'll let you know! Apr 27, 2017 at 7:22
  • Yes, that makes sense It's a pain that you can't pass across attributes to MobileConnect. This is a big limitation with MobileConnect and there's not really a perfect solution to this. I've come up with a way to match email subscribers and mobile contacts, but only when creating them using the REST API, which I can elaborate on if required. Apr 27, 2017 at 7:26
  • If my solution does work, then please feel free to accept my answer for the benefit of others :-) Apr 27, 2017 at 7:27
  • 1
    It will take some time to confirm. The mobile attribute can be created in the parent BU, but not the child BU where we need it - logged a case to get support to fix, think there's a provision error (the attributes doesn't transfer from parent to child, and, subscribers show in count from child to parent, but can't actually look them up). Will come back once everything is confirmed - thanks a million so far ! Apr 27, 2017 at 13:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .