Re: Restricting flow steps in Smart Campaign to M-S between 7am-6pm

Melody_Frieda1
Level 2

Restricting flow steps in Smart Campaign to M-S between 7am-6pm

Hi,

I have a pretty frustrating situation that I hope the Marketo Community can help me resolve. We have integrated a SMS and Voicemail platform called Call Loop into Marketo. Our goal is to test SMS and ringless voicemail as a means to increase "offer accept rates" of our loan product. I cannot for the life of me figure out how to keep a text message and voicemail from being triggered (via a webhook in the Smart Campaign) when someone applies for our loan "after hours" (between 7pm-6am in a person's respective time zone).

People can apply for a loan anytime on our website, and the ideal flow for this Smart Campaign would start like this for the first 36 hours:

Screen Shot 2018-07-31 at 5.05.12 PM.png

So in this example, the first step would look like this:

  • Email #1 would trigger 5 minutes after the applicant sees their offer
  • 10 minutes after the offer event, a text message is triggered
  • 30 minutes after the offer event, a ringless voicemail is sent out.


Second step looks like this

  • 12 hours after the offer event, an Email #2 is triggered
  • 30 minutes after Email #2 is triggered, a text message is sent out

The situation I'm trying to avoid is someone who applies at 3pm getting their second email and SMS at 3am. Or someone who applies at 11pm getting a pre-recorded ringless voicemail at 11:30pm prompting the applicant to call our customer service dept if they have questions about their loan offers (our customer service dept closes at 6pm)

This is just a snippet of the Smart Campaign we want to execute, but what is pivotal here is being able to define the hours in the day that these communications are acceptable to send--for example, defining the Smart Campaign to only send flow step items between 7am and 6pm Monday through Saturday.

Any suggestions on how to pull this off?

20 REPLIES 20
Jay_Jiang
Level 10

Re: Restricting flow steps in Smart Campaign to M-S between 7am-6pm

Have you tried adding Advanced Wait steps with "Must end on" before each action? However, you mentioned:

in a person's respective time zone

and

our customer service dept closes at 6pm

Which if you want to address both, then would require a more complex solution...

Jay_Jiang
Level 10

Re: Restricting flow steps in Smart Campaign to M-S between 7am-6pm

Actually, I understand your frustration now as Advanced Wait with "must end on" doesn't work so well with shorter wait durations. The only alternative I could think of that honours the after hours logic, was to write a webhook in php and have the script sleep until the right time, i.e. sleep 30 mins; if (current time is greater than current day 7pm){sleep until next day 6am}, before returning a response to a custom field which Marketo can use as a trigger to send the next comm. You'll need a developer with php knowledge if you want to go down this path.

SanfordWhiteman
Level 10 - Community Moderator

Re: Restricting flow steps in Smart Campaign to M-S between 7am-6pm

Webhooks time out after 30 seconds, so... nope!

(Also, this doesn't require knowledge of any particular language... you could write the webhook in Rust if that were your specialty. Any language can sleep, in fact PHP's sleep() is worse than most because of the process-oriented nature of the language.)

Jay_Jiang
Level 10

Re: Restricting flow steps in Smart Campaign to M-S between 7am-6pm

If not through a response, you can always curl to the /index.php/save endpoint.

Additionally, if you have a CRM integrated, you might have to see if your CRM can help with the flow on this one.

SanfordWhiteman
Level 10 - Community Moderator

Re: Restricting flow steps in Smart Campaign to M-S between 7am-6pm

Attempting to leave PHP processes sleeping for hours is really inadvisable, and at even limited scale it's impossible: look at the FPM and FCGI process limits for the why. I wouldn't put such a thing in production. You need either a real job queue or an async-capable language to implement this sleep-and-callback concept.

But the smoother implementation would be to not bother calling back to Marketo at all. The SMSes and voicemails are going out via a webhook already, and that's a good thing. Send them to a webhook gateway instead. That gateway gives the "queued" OK to Marketo, then adds the requests to its own internal queue. Jobs are only pulled off the queue and sent to the SMS provider during business hours.

Melody_Frieda1
Level 2

Re: Restricting flow steps in Smart Campaign to M-S between 7am-6pm

Hi Sanford Whiteman​ and Jay Jiang​--thanks for hopping on my question so quickly with potential solves. I can't be the only Marketo user that wants to limit timing of automated emails and other integrated touch points, so hopefully this answer helps some other folks out there...

Is there a good solution to force an email to wait (especially in the flow step where we say "wait 12 hours, then send") for scenarios where we have people applying for our loan product between 12pm-5am? I'd hate for our second email to be delivered between 12am and 5am, and get buried with all the other junk mail that gets sent overnight? We don't have a CRM integration (as an alternative option to explore).

@Sanford - I'm not as wizard coder by any stretch of the imagination...any recommendations for a Webhook gateway I can use to test restricting timing? This is a good solve for the SMS and Text side of things.

Thanks!!

Melody_Frieda1
Level 2

Re: Restricting flow steps in Smart Campaign to M-S between 7am-6pm

One last piece of information that can potentially help--one of our fields is a "datetime" field related to the date and time their loan offers were shown. The unfortunate part of this equation, once again, is that if I want to use that specific field on the flow step of the Smart Campaign, Marketo will only allow me to use the date, and not the time stamp--unless there's something else I can do to utilize that time stamp? I tried to see if using the Date Token in the wait step with this specific field is possible, but no luck.

Maybe there's a way to concatenate the time portion of the "datetime" field, and find a flow step that can properly use AND recognize that value? Open to any ideas...seems silly that there isn't a "snooze" feature in Marketo to avoid sending emails at inopportune times.

Mark_Price
Level 7

Re: Restricting flow steps in Smart Campaign to M-S between 7am-6pm

Hi Melody,

Here are some options that may help.  It sounds like you rather not write a bunch of code, so option A might work

A: use Sanford Whiteman​'s example which utilizes a 3rd party service called timezonedb (which means you don't have to host files but there is a small fee)

MktoForms2 :: TZ/Business Hours

^ this example utilizes a hidden custom field called: lastFormBizHours

B: Use some javascript and a custom field:

After doing some conversions for time- When the form is submitted you store 'In Business Hours' / 'Out of Business Hours' which can be used to trigger the correct Marketo campaign (immediate send vs wait until).  You will more than likely need code to accommodate Daylight Savings (pretty sure I ran into that last time)

*Note: You could use an existing library like: https://momentjs.com/timezone/ to make it a little easier; or since you already log date/time in a field- maybe break off time into it's own field and then use constraints for this value.

C:  Server side script + custom field + webhook :

Make a simple server side script that finds current time and returns 'In Business Hours / Out of Business Hours', then setup a webhook making sure to map the response to a custom field.  After that setup a Marketo campaign that calls the webhook.  Now you can utilize the 'In Business Hours' / 'Out of Business Hours' value to run the appropriate campaign.

SanfordWhiteman
Level 10 - Community Moderator

Re: Restricting flow steps in Smart Campaign to M-S between 7am-6pm

Yeah, [A] could be switched to use momentjs instead of timezonedb.  It's all about the easier API.

When it comes to the webhook, I think it needs to do more than a Boolean for in/out of business. It can write back to DateTime fields, and those fields can in turn be used in wait steps to send an email at the next legit time.