Context handler function

Context handler function


Context handler function is used to control the conversational flow of an action. You can change the order in which the params are prompted to the users in the runtime. You can also skip some params, do custom validations of the param values and ask for a confirmation before action execution in the runtime.

Please note that, the context handler function can override the order in which the static params are defined. If the context handler function is enabled, the bot will prompt the parameters in the order as dictated by the context handler function and not by the order you have declared while defining the params.

Invocation Point

Once Zia Skills detects the action of the user input, the possible param values that are present in the user input will be detected; then, the bot will prompt the first missing param to the user. When a user replies to the param prompt, Zia Skills will invoke the context handler function. Hence, context handler function is invoked for every param that is prompted in the conversation. If an action doesn’t have any params at all, the context handler function will be executed once before the execution function.

Input Arguments

In addition to the system defined input arguments, the following input arguments are also available for the Context handler function.

Argument
Deluge data type
Description
userInput
String
Latest reply from the user.
previousParam
Map
The param that is last prompted to the user. The user reply has been made as a value to this param.


Return Value

Context handler function must return a Map that should be in the following format.
{
    "todo":"prompt",
    "prompt":{
        "param_name":"<name of the param to be prompted>",
        "prompt_msg":"<the text to be displayed as a prompt message>",
        "options":[ ],
        "buttons":[ ],
        "fields":[ ],
        "submit_button_label":"<the text to be displayed as the label of the submission button in the form>",
        "more_button_label":"<the text to be displayed as the label of the 'more' button in the form>",
        "max_submissions_allowed":"<1-100>"
    },
    "confirm":{
        "message":"Are you sure you want to cancel?"
    },
    "assign":{
        "clientData":{ }
    }
}
As shown above, the following are the keys that can be present in the map that would be returned from the Context handler function.

The following are the keys that can be present in the map that would be returned from the context handler function.
  1. todo (mandatory) — Used to indicate what Zia Skills should do next after completing the context handler function. It can take one of the following values only.
    1. prompt — Instructs the bot to prompt a param to the user.
    2. confirm — Instructs the bot to ask for a final confirmation for invoking the execution function of the action.
    3. execute — Instructs Zia Skills to invoke the Action execution function.
  2. prompt (mandatory, only if “todo” is set as “prompt”) — Contains a map that specifies what param is to be prompted to the user. If this key is not provided even if “todo” is set as “prompt”, the bot will prompt the next param as per the order of the param definition. So this key can be skipped if we will have to use the default order of the params definition. The map value can contain the following keys.
    1. param_name  — The name of the param to be prompted. The param name should be one of the declared static or dynamic params.
    2. prompt_msg — Used to momentarily override the default prompt message of the param.
    3. optionsThe list of options of the single and multiple selection list params, only from which the user can choose.
      1. id — The unique id of the option.
      2. label — The text to be displayed as the option's label.
      3. preview - The additional information to be displayed for the options of the single select and multi select list params. Options previews will be available only when the input mode of the single select and multi select params is Visual.
        1. header  The properties of the single select and multi select list param options. The header object should contain the following keys in the below format.
          {
              "id":"<the unique id for the option>",
              "label":"<the text to be displayed as the option's label>",
              "preview":{
                  "header":{
                      "title":"<the text to be displayed as the option preview's title>",
                      "description":"<the text to be displayed as the option preview's description>",
                      "subheading":"<the text to be displayed as the subheading to the option's preview>",
                      "image":{
                          "url":"<the url of the preview image>"
                      }
                  }
              }
          }
          If the 'header' key is configured with these appropriate key values for the options, then the previews will be displayed when the user clicks the info icon   on each option.
                             
                                          In mobile, preview will be shown on 3D touch.
        1. fields The list of additional properties about the options. The "fields" object should contain the following keys in the below format.
          [
              {
                 "label":"<the text to be displayed as the field name>",
                 "value":"<the text to be displayed as the field value>"
              }
          ]
          If the "preview" object is configured for an option, then the 'fields' object should be mandatorily defined for it. A maximum of seven fields can be configured for an option.
The key elements of the "preview" object are, "header" and "fields".  If the "fields" object alone is configured for a "preview" object, then the previews will be displayed when the user hovers on the respective options.
                    

Availability of previewing the single select and multi select options
  1. Supported Minimum client SDK version - 2.4.0.
  2. Not available for bots in other Zoho services.

Note :  The 'preview' key is not a mandatory field that is required to be given for a single select/ multi select list param object. 
    1. buttons Buttons are the preferred actions to be performed on the selected single select/multi select options. This is applicable only for the single and multiple selection list params. The "buttons" object should contain the following keys in the below format.
      [
          {
              "id":"the unique id for the button",
              "label":"the text to be displayed as the button's label",
              "theme":"<positive | neutral | negative>"
          }
      ]
      Note: A single / multi selection list param can have up to 3 buttons.

    2. fields Used to configure the fields and its properties for the "Form" param. The "fields" object should contain the following keys in the below format.
      [
          {
              "label":"<label of the field>",
              "name":"<unique name to identify the field>",
              "type":"<valid param types>",
              "mandatory":"true | false",
              "default_value":"<valid value based on the respective field type>"
          }
      ]
      1. mandatory — If "true", then that respective field should be compulsorily filled by the user.  It is "true" by default.
      2. For "type", the valid field types are: STRING, NUMBER, DATE, TIME, EMAIL, ARRAY_CHECKBOX, ARRAY_RADIO, DATE_RANGE, TIME_RANGE, DECIMAL_RANGE, and INTEGER_RANGE.
      Note: A maximum of 10 fields can be configured for a form.

    3. submit_button_label — The text that should be displayed as the label of the submission button in the form. This is applicable only for the "Form" param.
    4. more_button_label — The text that should be displayed as the label of the 'Save and add' button in the form. This is applicable only for the "Form" param.
      Note: If "submit_button_label" and "more_button_label" are not configured for the "Form" param, then these buttons will be labelled as "Save", "Save and add" respectively by default.
    1. max_submissions_allowed — To specify the no. of submissions of the form that can be made by the user. You can specify the value of this key from 1 to 100. By default, the value of this key is "100". This key is applicable in configuring a form only when the "Allow multiple entries" toggle switch is enabled while creating the "Form" param.
  1. confirm (mandatory only if “todo” is set as “confirm”) — Contains a map that specifies the confirmation message for action execution that should be prompted to the user. The map value can contain only the following key.
    1. message — The confirmation message that should be prompted to the user.
  2. assign — The value of this key should be a map. This key is used to change the values to any of the mutable input arguments of the function. All the static params and the system defined argument “cache” are mutable.
    1. clientData — Used to update the client data values of the session data in the runtime.

      Create. Review. Publish.

      Write, edit, collaborate on, and publish documents to different content management platforms.

      Get Started Now


        Access your files securely from anywhere

          Zoho CRM Training Programs

          Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.

          Zoho CRM Training
            Redefine the way you work
            with Zoho Workplace

              Zoho DataPrep Personalized Demo

              If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.

              Zoho CRM Training

                Create, share, and deliver

                beautiful slides from anywhere.

                Get Started Now


                  Zoho Sign now offers specialized one-on-one training for both administrators and developers.

                  BOOK A SESSION







                              Quick LinksWorkflow AutomationData Collection
                              Web FormsEnterpriseOnline Data Collection Tool
                              Embeddable FormsBankingBegin Data Collection
                              Interactive FormsWorkplaceData Collection App
                              CRM FormsCustomer ServiceAccessible Forms
                              Digital FormsMarketingForms for Small Business
                              HTML FormsEducationForms for Enterprise
                              Contact FormsE-commerceForms for any business
                              Lead Generation FormsHealthcareForms for Startups
                              Wordpress FormsCustomer onboardingForms for Small Business
                              No Code FormsConstructionRSVP tool for holidays
                              Free FormsTravelFeatures for Order Forms
                              Prefill FormsNon-Profit
                              Intake FormsLegalMobile App
                              Form DesignerHRMobile Forms
                              Card FormsFoodOffline Forms
                              Assign FormsPhotographyMobile Forms Features
                              Translate FormsReal EstateKiosk in Mobile Forms
                              Electronic Forms
                              Drag & drop form builder

                              Notification Emails for FormsAlternativesSecurity & Compliance
                              Holiday FormsGoogle Forms alternative GDPR
                              Form to PDFJotform alternativeHIPAA Forms
                              Email FormsEncrypted Forms

                              Secure Forms

                              WCAG

                                      Create. Review. Publish.

                                      Write, edit, collaborate on, and publish documents to different content management platforms.

                                      Get Started Now






                                                        You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.




                                                            Manage your brands on social media

                                                              Use cases

                                                              Make the most of Zoho Desk with the use cases.

                                                               
                                                                

                                                              eBooks

                                                              Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho Desk.

                                                               
                                                                

                                                              Videos

                                                              Watch comprehensive videos on features and other important topics that will help you master Zoho Desk.

                                                               
                                                                

                                                              Webinar

                                                              Sign up for our webinars and learn the Zoho Desk basics, from customization to automation and more

                                                               
                                                                
                                                              • Desk Community Learning Series


                                                              • Meetups


                                                              • Ask the Experts


                                                              • Kbase


                                                              • Resources


                                                              • Glossary


                                                              • Desk Marketplace


                                                              • MVP Corner

                                                                Zoho Sheet Resources

                                                                 

                                                                    Zoho Forms Resources


                                                                      Secure your business
                                                                      communication with Zoho Mail


                                                                      Mail on the move with
                                                                      Zoho Mail mobile application

                                                                        Stay on top of your schedule
                                                                        at all times


                                                                        Carry your calendar with you
                                                                        Anytime, anywhere




                                                                              Zoho Sign Resources

                                                                                Sign, Paperless!

                                                                                Sign and send business documents on the go!

                                                                                Get Started Now




                                                                                        Zoho TeamInbox Resources





                                                                                                  Zoho DataPrep Demo

                                                                                                  Get a personalized demo or POC

                                                                                                  REGISTER NOW


                                                                                                    Design. Discuss. Deliver.

                                                                                                    Create visually engaging stories with Zoho Show.

                                                                                                    Get Started Now









                                                                                                                        • Related Articles

                                                                                                                        • Action Execution function

                                                                                                                          The Execution function is the endpoint to an action execution. It defines the fulfillment of an action. This does the actual execution of the action and gives a final success (or failure) message to the user, as a result of the completion of an ...
                                                                                                                        • Fallback Function

                                                                                                                          When a bot receives an input message that it couldn't understand, it would reply with a "Sorry, I can't understand" message. If you wish to customize this default response message to give a reply of your own, you can customize that with Fallback ...
                                                                                                                        • Zoho SalesIQ: A sample Zobot powered by Zia Skills

                                                                                                                          Zobot is Zoho SalesIQ's virtual chat agent that is designed to interact with website visitors conversationally. Zobot automates the process of interacting with website visitors and helps to maintain the presence of a helping hand, even when all the ...
                                                                                                                        • Model & Flow of Actions

                                                                                                                          An Action of a Zia bot is characterized by its Sample sentences, Params and Functions. Params Params are the input data that are required to fulfill or execute an action. If we consider the execution of an action analogous to filling a form, then the ...
                                                                                                                        • Defining an Action

                                                                                                                          Adding a New Action To add a new Action to a Skill, follow the steps as given below. In the Skill's details page, under the ACTIONS tab, click the + ADD ACTION option. The Create New Action page appears. Give a meaningful name for the action. Based ...
                                                                                                                          Wherever you are is as good as
                                                                                                                          your workplace

                                                                                                                            Resources

                                                                                                                            Videos

                                                                                                                            Watch comprehensive videos on features and other important topics that will help you master Zoho CRM.



                                                                                                                            eBooks

                                                                                                                            Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho CRM.



                                                                                                                            Webinars

                                                                                                                            Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.



                                                                                                                            CRM Tips

                                                                                                                            Make the most of Zoho CRM with these useful tips.



                                                                                                                              Zoho Show Resources