Control at SAP CPI the sending date of messages from SAP Marketing Cloud campaigns to don’t send messages on Sundays and Holidays
One of the most important features that companies use in the Digital Marketing tools is to send successful campaigns to engage their customers and contacts.
At SAP Marketing Cloud, there is a lot of configuration that you can apply to set up the best way to send these campaigns to the contacts. But, sometimes these configurations aren’t enough for some special requirements…
We have a customer that sends SMS campaigns from SAP Marketing Cloud to a text message service provider using an integration flow at SAP CPI. However, our customer didn’t want the SMS messages to be sent to his contacts on Sundays and Holidays, and he wanted these messages to be stored and sent on the next available day.
The part of “don’t send messages on Sundays”, we can manage this in the campaign configuration at SAP Marketing Cloud, as you can see in the image below.
But, the requirement “don’t send messages on Holidays” aren’t available by default at SAP Marketing Cloud. So, what we did? We configured and managed these requirements in the integration flow at SAP CPI.
In this blog, you’ll see how I and my partner Danielle Lucarini created a solution at SAP CPI to receive the messages from a SAP Marketing Cloud SMS Campaign, check if it’s or not an allowed day to send the messages, and in the case that is a Sunday or a Holiday, the message is stored in SAP CPI and it’s sent in the next allowed day.
The Solution Steps
In the integration flow to receive the SMS message and send it to the service provider, we added a condition with a Groovy Script and a Router steps to validate if it is a Holiday or a Sunday.
The SundayValidation Script does the validation to determine if it is Sunday or not. It does this validation by checking the current datetime. The same script also validates if it is a Holiday or not. This validation is done based on the previous values added in the externalization parameters. These values include the Holiday dates.
If the validation determines that it is not a Sunday or a holiday, the message is transformed with a script and it’s sent to the service provider.
But if the validation determines that it is a holiday or Sunday, the message is sent to a local integration process, which generates an XML file and stores it in a datastore inside CPI.
After processing these messages that were saved in the datastore, an additional iflow was created that runs at specific times, which reads the saved messages and performs again the validation on Sunday or holidays. Depending on the result of this validation, the iflow sends the message to the service provider or keeps saving it in the datastore.
To avoid errors in the log of the campaigns in SAP Marketing Cloud because the messages didn’t send on Sundays and Holidays, we send in response to SAP Marketing Cloud telling that all messages were sent in the original date. But as they were actually sent with a different date, we need to update the interaction date of the sending SMS in SAP Marketing Cloud, to have the real information on it after all the processing.
This update is done in other local integration process at the same integration flow which processes the saved messages.
First, we do a GET request to the SAP Marketing Cloud Interactions API to get the Token to enable us to send other requests to it, then we do a PATCH request to the same API in order to update, with the real date, the interaction that was created before.
To summarize, this integration flow is able to control the right date to allow the sending of the messages created in the SAP Marketing Cloud campaigns. It verifies if the date is or not Sundays or Holidays, and manage to do the right steps based on this validation, in order to always send the messages only in the days that our customer really wants to send his campaigns to his contacts. And our customer doesn’t need to worry about do all this management, because it’s everything done automatically at the SAP CPI integration flow.