Seasonal Greetings

The first thing your users will see when starting a conversation with your chatbot is the Greeting Message. You will have thought about what information to include in the message to best salute your users, set the expectations and guide them into the conversation with the chatbot.

GreetingMessage

Did you also consider that you can make these greetings contextual to the time of day, the day or even a period of time?

In this article we will explore when you want to consider varying your responses based on the time or date, and how you can do so.

When should you consider adapting the answer based on time or date?

Adapting your answers to time or date could really be relevant for any kind of answer, depending on the content, but a couple of use cases stand out:

The Greeting Message

Making your bot’s greeting reflect the time of the day can be a nice little feature to make the answer text more friendly and humanlike, and it will also allow you to promote certain content at specific times. For instance, we could adapt Lisa’s greeting message to greet the early visitors with a friendly good morning greeting, or to inform about the cookie hour to those chatting with her in the afternoon

Questions related to opening hours

If your company has opening hours, the responses should also be adapted to the time. Lisa may be available 24/7, but her human colleagues that actually make the coffees are probably not, and Lisa should know that and respond accordingly. So if someone asks “are you open now?” at 2:00 AM, Lisa would say that her human friends are sleeping and not take any coffee orders, but at 8:00 AM the same question would get a different response.

Seasonal content

In most companies there will be times where certain products or processes are available. Taking the example of a process, a company with an HR chatbot will want to make sure that the chatbot knows when for instance the performance reviews take place and inform accordingly when asked, without the developers having to build/delete or enable/disable content constantly, with the risk of forgetting. It could also be that your chatbot is of the chatty type, and you want to make it give a special greeting for Christmas, New Year, Halloween, Eid, Hanukkah, the International Coffee Day or any other celebration of importance to your company or your target users. Maybe even pirates drink coffee and will appreciate a special greeting on their day?

TalkLikeaPirate

What do you need to be able to adapt the responses based on date & time?

To enable this feature in your bot, you basically need to make your bot aware of the time and date of the communication. This can be done in different ways, but when you start your project with the

Conversational Module in Teneo, your Greeting Message flow will contain the basics for setting up this feature: a flow script and four flow variables. The script will populate the four variables with information about:

  • Current hour
  • Current day
  • Current month
  • Current year

The time zone is defined in a global variable, and it should of course be adjusted to reflect the time zone of the company that the chatbot represents.

FlowScript

This script enables a Greeting Message flow as below, where different greetings are given according to time of day (morning/afternoon/evening), and to date & month (Seasonal Greeting).

GreetingMessage

On each transition, the Teneo Engine will look at match requirements based on the hour/time/date variables to determine which response should be given, like in this example from the transition “The time is 6 to 12” where the engine validates if the value of the variable iHour is equal to or greater than 6 and equal to or smaller than 11.

ScriptMatchRequirement

Note that the script and variables in the Greeting Message flow will only allow the Greeting Message flow to adapt its behavior according to time and day. If you want to be able to adapt the behavior of more flows in your solution, you need to make the information available to all flows by moving this script from the flow to the global Pre-processing script, as well the variables from the flow to Global variables.

Another option for adding match requirements based on time & date is to create a context restriction based on the time of the day. Context restrictions are available to all flows in the solution, and with the example below, you could achieve a behavior similar to having a global script and global variables as described above. Furthermore, in context restrictions, all states controlled centrally which can be an advantage if more flows need to apply the same logic regarding time restrictions.

ContextRestriction

Summary

So, knowing the above, maybe you would want to consider letting your chatbot get into the Christmas Spirit by adding a little twist to the greeting message? To do so,
  1. Copy this script into the “On Top” script of your Greeting Message flow
TimeZone timeZone = TimeZone.getTimeZone(Lib_sUserTimeZone);
iHour = Integer.parseInt(String.format('%tH', new GregorianCalendar(timeZone)));

// The below script add values for current day, month and year to the variables Lib_iDay, Lib_iMonth and Lib_iYear.
 
def c = Calendar.getInstance()
Lib_iDay = c.get(Calendar.DAY_OF_MONTH)
Lib_iMonth = c.get(Calendar.MONTH) + 1 // Returns 0..11
Lib_iYear = c.get(Calendar.YEAR)
  1. Add the flow variables
  • Name: iHour, Value: 0
  • Name: Lib_iDay, Value: 0
  • Name: Lib_iMonth, Value: 0
  • Name: Lib_iYear, Value: 0
  1. Add a new output node and make the transition match conditionally with the condition

Lib_iMonth==12 && Lib_iDay>23

  1. Add your Christmas Greeting of choice

Now your bot should be all set to spread some Christmas spirit

HolidayBot


A Teneo Tuesday article. #TeneoTuesday

3 Likes