You can use both business rules and workflows to send automated SMS responses to initial-inbound messages. While both options result in the same general outcome, there are advantages and disadvantages of each.Ā
In this article we will go over the benefits and differences between automating SMS responses with business rules vs workflows and how you can do either.Ā
Prerequisites
Set up an SMS integration and connect the number to Kustomer
Business Rule
Using a business rule is the simplest way to set up an SMS auto-response and can be done in just a few minutes. The business rule editor allows you to use a template to generate a working auto-responder with the click of a button. From there you are able to customize your conditional logic and messaging to get it to fit your needs. While business rules are simpler and quicker they do lack some of the features available in a workflow.Ā
In order to create a business rule to send an SMS auto response, follow the guide below
Create a rule using the template
Start by going to settings > platform > business rules and then clicking āadd ruleā
The best way to get started is to use a templateĀ
Under āuse casesā click on āsend messageā and select SMS acknowledgement auto response
This will set the rule up to trigger on the first-inbound interaction (first message sent in from the customer) and will add a condition to make sure the conversation was not imported.Ā
Lastly, it set up the āsend messageā action to have SMS as the channel and your default SMS number as the āfromā number
Add your conditions
The only condition added by the template is āconversation imported At is not setā
You will need to add any additional conditions you want to filter out which types of customers, conversations and messages will receive the auto response
Customize your message
Add whatever text you want in your message body and format and style it to your liking
If you have more than one number in your org you can also choose which number you want to the auto response to be sent fromĀ
Activate and save the business rule
Finally, activate and save the rule to put it into action
WorkflowĀ
Using a workflow to set up an SMS auto response allows for greater levels of customization than a business rule. Workflows give you access to a wider variety of attributes to use for conditions or include in your message body. In addition to sending the message, workflows also allow you to accomplish multiple tasks at or around the same time to further increase productivity. Workflows also give you the ability to delay the message being sent for a specific duration.Ā
In order to set up a workflow to send an automatic SMS reply on an inbound message, you will need to follow the guide belowĀ Ā
Create an API key and save it as a workflow variable
Create an API key with org.permission.draft.create and org.user.draft.write permissions
Make sure you set the key to not expire so that the workflow does not stop working down the road due to an authentication error
Save API key as workflow variable
Create the workflow trigger
Add āmessage createdā as the triggerĀ
This will only trigger the workflow for a new message created in KustomerĀ
Add condition steps
Add a condition step to make sure the message is the initial inbound message
This will ensure that sending a message from an agent to a customer does not result in an auto response being sentĀ
Add a condition step to make sure the message was not importedĀ
This is necessary to ensure that only active conversations with live customers are getting auto responsesĀ
Look up the conversation
Add a āconversation lookupā step to get information on the conversation the message exists on
To do this, utilize the āconversationā attribute from the message object (steps.1.conversation)
This value is the conversation ID
Send the message via the API
Lastly, add a āRest API: JSONā step to send an API POST request to the /drafts endpoint. This will create send the SMS message
Your URI will be https://<org_name>.api.kustomerapp.com/v1/customers/{{steps.1.customer}}/drafts
Your method will be POST
This creates a new message
The data section will include the necessary attributes to complete the message sending process and will be formatted as JSON and placed between two curly brackets {}
Here is an example of the request data
{
Ā Ā 'channel': 'sms',
Ā Ā 'conversation': '/#steps.1.conversation',
Ā Ā 'sendAt': '{{{date 'day' count=0}}}',
Ā Ā 'from': '/#steps.1.meta.to',
Ā Ā 'to': '/#steps.1.meta.from',
Ā Ā 'body': '<MESSAGE_BODY_HERE>'
}
You will utilize the message data from step 1 and the conversation data from step 3 to fill in the request body
The āsendAtā value is what is used to tell the message to send immediately as opposed to on a delay
For your headers, you will need to utilize the API key you saved as a workflow variable.Ā
The headers should also be formatted in JSON like so
{
Ā Ā 'Authorization': 'Bearer ',
Ā Ā 'Content-Type': 'application/json'
}
Add your API key after āBearerā by clicking the key icon and copy and pasting it
This allows you to hide and protect your API keyĀ
Lastly, you will need to make sure you select ātrueā for the ājsonā attributeĀ
Best Practices
In a workflow, save the API Key as workflow variable to avoid exposing the key
Utilize a custom attribute to avoid repeats and loops
Create a custom attribute on the conversation klass called āauto response sentā with a ātrue/falseā valueĀ
Add a condition in the business rule that prevents the message from being sent if āauto response sentā is equal to true
In the āset actionsā section of the rule, add an action to āupdate dataā and set the value of āauto response sentā to true
This will prevent multiple auto responses from being sent and limit the number of automated messages to 1 per conversationĀ
Markdown for styling message body
You can use markdown to format and style the body of your message
For example, add ** on either side of the text you want to make bold
**bold text**