In this post, we're going to shed light on how important it is for a bot to greet subscribers with a welcome message. We'll also be looking at how to configure a simple yet effective welcome handler!
A welcome message is the first and the most important action / interaction performed by your bot. But why is it so important?
- A message that explains the user what the bot does will provide them with a concrete understanding of how the bot can help them.
- Including a call to action, such an instant button in the message will show the user how easy it is to interact with the bot.
Working of the bot welcome handler
The bot welcome handler will be triggered to send a message when a user subscribes to a bot. Another interesting fact is that, the handler can also send a message to a user if they unsubscribe and subscribe to the bot again! There are a list of attributes passed when a welcome handler is triggered. Take a look at them in our welcome handler help page.
Sample Scenario
Let us try to build a conference bot with a welcome message explaining the user on what the bot does and a call to action. Assuming the conference has a hackathon event where participants are encouraged to build applications. The welcome handler should serve the following purposes :
- The welcome message will explain all the necessary details- about the verticals available, how to get started with their application, so on and so forth.
- A call to action for the user to select their choice of vertical under which they can submit the application.
- Each entry from the user will be added to the creator form to maintain a record.
Sample Welcome Handler Code
- response = Map();
- response = {"text":" Hey *" + user.get("first_name") + "* ! \n Welcome to ZylCal Developers Conference -2017 and thank you for subscribing! I'm here to help you with the following : \n Session Timings \n Session Overview \n Feedback \n ZylCal Hackathon \n Click on any of the buttons know more about the respective topics! [+Sessions](invoke.function|conference|li.jung@zylker.com|session-1) [+Hackathon](invoke.function|conference|li.jung@zylker.com|hack-2)"};
- return response;
Sample Functions Execution Code
- response = Map();
- message = Map();
- button_name = target.get("name");
- key = arguments.get("key");
- // details = zoho.creator.getRecords("<app_creator_name>","<application_name>","<form_name>","<condition>",1,1,"<insert_connection_name> ", <user_access>);
- details = zoho.creator.getRecords("lijungdeveloper","test","Sessions_Report","ID1 == 100",1,1," <insert_connection_name> ",true);
- if(key.matches("session-1"))
- {
- overview = details.toMap().get("Session_Overview");
- feedback = details.toMap().get("Feedback");
- response = {"text":" Please refer the session information (Details, Timings) from here! \n Session Overview: " + overview + " \n Feedback: " + feedback,"bot":{"name":"ZylCal Conf Bot","image":" <insert_bot_image_url> "}};
- }
- else if(key.matches("hack-2"))
- {
- response = {"text":"The hackathon event involves developing applications under any of these categories. Select any category to register with your name and email ID. \n [+Productivity](invoke.function|conference|li.jung@zylker.com|101) [+IT-Admin](invoke.function|conference|li.jung@zylker.com|102) [+Entertainment](invoke.function|conference|li.jung@zylker.com|103)","bot":{"name":"ZylCal Conf Bot","image":" <insert_bot_image_url> "}};
- }
- else if(key.matches("101"))
- {
- dataMap = {"Resp":target.get("name"),"zuid":user.get("email")};
- record = zoho.creator.createRecord("lijungdeveloper","test","Hackathon",dataMap,"zohocreator2",true);
- response = {"text":"Awesome! Your name has been registered under the *" + target.get("name") + "* category! All the best. :grinning:","bot":{"name":"ZylCal Conf Bot","image":" <insert_bot_image_url> "}};
- }
- else if(key.matches("102"))
- {
- dataMap = {"Resp":target.get("name"),"zuid":user.get("email")};
- record = zoho.creator.createRecord("lijungdeveloper","test","Hackathon",dataMap,"zohocreator2",true);
- response = {"text":"Awesome! Your name has been registered under the *" + target.get("name") + "* category! All the best. :grinning:","bot":{"name":"ZylCal Conf Bot","image":" <insert_bot_image_url> "}};
- }
- else if(key.matches("103"))
- {
- dataMap = {"Resp":target.get("name"),"zuid":user.get("email")};
- record = zoho.creator.createRecord("lijungdeveloper","test","Hackathon",dataMap,"zohocreator2",true);
- response = {"text":"Awesome! Your name has been registered under the *" + target.get("name") + "* category! All the best. :grinning:","bot":{"name":"ZylCal Conf Bot","image":" <insert_bot_image_url> "}};
- }
- else
- {
- response = {"text":"I can only help you with these right now! To know any other information please contact support@zylcal.com"};
- }
- post = zoho.cliq.postToChat(chat.get("id"),response);
- return message;
The slide show below will give a better understanding of the sample execution!
The welcome handler sets an opening tone to the bot and also establishes a connection between the user and the bot. Try using this sample code snippet and let us know what you think! Comments and suggestions are welcome.
Few useful links:
Best,
Manasa
Cliq