Welcome Message Handler

Introduction

When a ConvoKraft bot is opened by the user for a fresh chat session, the bot will reply with a welcome message. If you wish to customize this default response message to give a reply of your own, you can configure it in the Welcome Message handler function. The Welcome message handler function returns a map whose structure is similar to the return map of an Execution function.

Note : If the chosen development platform of your ConvoKraft bot is either Catalyst functions or Webhooks, you can enable the handler from the console and define the logic of your handler functions either in the Integration Function or in the codebase associated with the configured webhook URL respectively.

To learn more about defining handler functions in Deluge, please refer to this page.

If you have chosen your development platform to be Functions, you can use the below listed sample codes for the Java, Node.js and Python stacks :

Java

    
copy
import org.json.JSONObject; import java.io.*; import java.util.logging.Logger; public class WelcomeHandler { Logger LOGGER = Logger.getLogger(WelcomeHandler.class.getName()); public JSONObject handleWelcomeRequest(JSONObject reqBody) throws Exception{ LOGGER.info("Welcome Handler: : TODO : "+ reqBody.get("todo")); JSONObject welcomeResponse = new JSONObject(); welcomeResponse.put("message", "Welcome to your Bot. Please ask your queries"); JSONObject jsonResponse = new JSONObject(); jsonResponse.put("welcome_response", welcomeResponse); return jsonResponse; } }

Node.js

    
copy
import logger from "./logger.js"; // Handle the welcome functionality export default function handleWelcome() { logger.info('Handling welcome request'); return { "welcome_response": { "message": "Welcome to your Bot. Please ask your queries" } }; }

Python

    
copy
import logging def handle_welcome_request(): # This is your Welcome message Handler. # You need to write the default Welcome message your want your bot to greet its users. # The way to return welcome message is as follows : # { # 'welcome_response': { # 'message': 'Welcome to your Bot. Please ask your queries' # } # } # Sample code to set the same is available Below. logging.info('Handling welcome request') return { 'welcome_response': { 'message': 'Welcome to your Bot. Please ask your queries' } }

Last Updated 2024-06-11 18:57:28 +0530 +0530

ON THIS PAGE