20 Replies Latest reply on Aug 3, 2018 4:10 PM by Melody Frieda

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

    Melody Frieda

      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?

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

          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...

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

              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.

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

                  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.)

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

                      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.

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

                          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.

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

                              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!!

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

                      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.

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

                          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.

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

                              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.

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

                                Thanks Mark, for the feedback and options--and Sanford Whiteman for chipping in again.  Do the above options depend on a Marketo form submission? If so, it won't work for us. We have an application online that sends information to a centralized databased--and that is what is connected to Marketo via API. I would trigger this campaign (actually all of my campaigns) from Data Value Changes.

                                 

                                Ideally I need a solution that requires minimal "coding" experience. Something simple like:

                                • Concatenate time stamp from DateTime field to it's own custom field
                                • Smart campaign is able to look up value of field (assuming Marketo smart campaign's understand how to read timestamped values in fields--example "If timestamp field is greater than 7:00:00 PM, place into 'Afterhours' list"--and another  smart campaign would have to be created to replicate the original smart campaign, but correcting for afterhours applicants)

                                 

                                 

                                I'm a just a lowly Marketer with zero budget for data architects hoping to hack this together on my own :-(

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

                                    Hi Melody,

                                     

                                    Options A and B aren't Marketo Form specific, but the example certainly is.  Those solutions are intended to be used when data is submitted somewhere (but doesn't have to be Marketo).  If using the API, you would basically just add another field to that process and when the data is added via the API include the new data point. 

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

                                      Melody Frieda

                                       

                                      The options that Sanford and others have suggested using a webhook with a gateway are ideal and the most scalable. FlowBoost is good for that.

                                       

                                      However if you want a "no-code" version, you can check out this post I wrote a few years ago: https://nation.marketo.com/community/champion/blog/2016/01/19/marketo-time-based-logic-for-emails-lead-routing-and-more

                                       

                                      I might do a few things differently if I was writing the post today, but it gives you the gist of things. Instead of triggering on the form fill you can do a time stamp on your data value change and calculate from there.

                                       

                                      It does require SFDC to do a CASE formula for the day of week though.

                                       

                                      Justin 

                                      • Re: Restricting flow steps in Smart Campaign to M-S between 7am-6pm
                                        Sanford Whiteman
                                        • Concatenate time stamp from DateTime field to it's own custom field

                                        Think you mean "split" (deconcatenate) as opposed to "concatenate". Though actually you don't need to worry about this if — as should be becoming clear with everyone's input! — you're going to be passing the token to an external service. That service can handle just looking at the time portion, you don't have to split it out beforehand.

                                         

                                        • Smart campaign is able to look up value of field (assuming Marketo smart campaign's understand how to read timestamped values in fields--example "If timestamp field is greater than 7:00:00 PM, place into 'Afterhours' list"

                                        There's no such thing as a Time-only datatype, only Date and DateTime, though you can use an Integer field to store the seconds in a day. But you don't need to worry about this workaround, because the heavy lifting is going to be done by the external service you call as a webhook. The service will write to DateTime and/or Boolean fields.

                                         

                                        As Sydney mentions, said service could be built on a freeform webhook platform like FlowBoost: FB happens to be JavaScript-powered, so in that case the webhook payload -- the script code -- would naturally be JS.

                                         

                                        Or you could build a bespoke service that does this one function, and any language could be used; Jay favors PHP, for example, and as long as you don't try to sleep any processes (just returning data immediately from the 'hook) that would work fine. Someone else might turn it around quickest in Python or Java or whatever they know.

                                         

                                        But no matter what the underlying code is written in, you're gonna need something custom to get this done.  You don't have to write the code, just provide a block of configuration info (in the case that Sydney's talking about, there's a {{my.token}} with the business hours, business days, timezones and such, and that's all that the end user ever needs to touch, so they aren't touching the code itself).  But believe us when we say that there isn't a hack that doesn't use an external service to some degree.

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

                                    Hey Melody! Similar to what Sanford Whiteman mentioned, I've accomplished this functionality (with Sanford's help) using a webhook called Flowboost. The code in the webhook checked if the current time was acceptable (there was an array of blackout dates which were holidays, weekends were always blacked out, and there was a timezone variable to handle sending in different time zones) then a campaign was requested to execute the desired operation, if not a campaign was requested to wait until the next morning then check again.

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

                                      Hi Melody,

                                       

                                      Thought I would throw this out there - not a total solution for what you're trying to accomplish, but it's another way to think about business hours. We don't use wait steps. We basically want to stop automated emails from sending outside of our business hours (not the lead's time zone) and so we date time stamp users in a "Email System Time Field" and then use a smart list (screenshot below) to see if they are in our defined business hours. If they qualify for the smart list - we send the email. If they don't - we add them to a static list. Then we have a batch campaign that runs M-F at the beginning of our business hours to users that came in during the night/weekend. For holidays, we have an extra step to pause these emails from sending. 

                                       

                                      Business Hours Smart List.jpg

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

                                          Ah, but it seems like you already have a String field you're using to represent only the time, which is exactly what the OP doesn't have! (I would've done this w/24-hour time -- no need to deal with AM/PM.)

                                           

                                          You're on to something in the sense that you can run change Change Data Value against a String field, with the new value a DateTime {{lead.}} token. This will give you the ISO 8601 string representation (mmmm-YY-dd hh:MM:ss) of the date. That string always has a space before the hour (hh). Out-of-the-box you can't search on a leading space (it's stripped out) but if you hack around that using the same mechanism I use to create line break tokens, you can filter on the leading space followed by the hour.  It would be really fragile, though.

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

                                            Thanks, Diane! I'm going to try and set up a similar solution

                                             

                                            Data Set Up

                                            1. I set up a smart campaign based on the trigger of the existing datetime field value changing (happens at the time of application)
                                              1. I created a separate custom field called Application Time that will stamp the system time into the field the moment the datetime field for the application updates
                                            2. I created a smart campaign that will append time zone information at the time of application into a custom field based on the State value
                                              1. Example: If State= Oregon, Washington, California, Nevada  |   Then: Change Data Value for Time Zone field to "Pacific"

                                             

                                            Campaign Set Up

                                            1. I created a smart campaign that will take the eligible population for our sms/voicemail test, and split them into six separate timezone lists (three time zones split into business hours vs non-business hours) similar to how you defined your campaign above

                                             

                                            The ultimate goal (when we have resources and budget) is to execute on something closer to what Sanford/Justin/Mark suggested to reduce the fragile/complex setup of these campaigns.

                                             

                                            THANK YOU, EVERYONE, FOR THE HELP AND SUGGESTIONS! The Marketo Community is AWESOME!