Execution Function

Introduction

The Execution function is the endpoint of an action execution. It defines the fulfillment of an action. This handles the actual execution of the action and gives a final success or failure message to the user, after the completion of an action. The response to the user can either be text or visual elements such as a collection of cards.

Invocation Point

The Execution function is invoked at the endpoint of an action. By default, the endpoint of an action comes after all the param values are prompted and are filled with proper values. Alternatively, the endpoint can also be triggered from the context handler function (“todo” : “execute”). After the execution function is invoked, the action is completed and any further conversation from the user will be considered as a new action.

Input Arguments

The system defined input arguments are only available as input arguments of the Execution function.

Return Values

The execution function returns a map in the following format:

    
copy
{ “message” : “The reply message.”, “card” : { }, "broadcast" : { }, "followup" : { } }

The keys present in the map returned by the execution function are explained below :

message

This gives a text message as a reply to the user and this key is mandatory. The following text formatting options are supported by ConvoKraft. Any of these options can be used in the text message.

Formatting option Syntax
Bold *text*
Italic _text_
Underline __text__
Strikethrough ~text~
Link [label](URL_link)
Highlight `text`
Heading h1 - #Heading h2 - ##Heading h3 - ###Heading h4 - ####Heading h5 - #####Heading
Bullet list * first_item \n * second_item \n * third_item
Numbered list 1. first_item \n 2. second_item \n 3. third_item
Image ![alternate_text](image_URL)
Blockquote !text
Table | header1 | header2 | header3 | \n |------------|------------|------------| \n | value1 | value2 | value3 | \n | value1 | value2 | value3 |

The following is a sample value of the message argument :

    
copy
message : "Your event has been created successfully"

card

This gives a visually formatted message as a reply to the user. A card is a collection of visual elements such as tables, images, and more. The value of this key is a list of map objects. Each map object represents an UI element in the card. A single card may contain more than one element of the same type. Every element in the card will be displayed one below the other in the reply message and this key is optional.

To learn more about the list of UI elements that are supported in ConvoKraft’s reply message card, please refer to this page.

The following is a sample value of the card argument :

    
copy
"card" : { "type" : "note", "content" : "Your event details are displayed below" { "type" : "image", "image" : "event_details.png" } //add map objects }

broadcast

This will pass any data that the bot must remember after executing the current action. The value should be in map format and it would be available for all consecutive actions throughout the session. This key is optional. You can learn more about broadcast from this page.

The following is a sample value of the broadcast argument.

    
copy
"broadcast" : { "user_level" : "admin", "status" : "booked" }

followup

You can configure if the bot should display a list of suggestions or prompt the user to invoke any particular action as a followup, after completing the current action’s execution. This key is optional. Learn more about Action Followups and the structure of this key’s value from this page.

The following is a sample value of the card argument :

    
copy
"followup":{ "suggestions":[ { "message":"Would you like to set a reminder for this event", "action":{ "name":"schedule remainder", "params":[ { "name":"event time", "value":"11:00 am" } //add other params as necessary ] } }

Implementation

Once you create an action for your ConvoKraft bot and choose to configure the response based on a business logic, you must define the sample sentences and respective params for it. Please make sure to follow the below listed steps to implement the Execution function :

  1. After you configure and save the required sample sentences and params for an action, the Action’s details page will be displayed. Switch to Functions tab and click Edit Function in the Execution function section.

edit-function-execution

  1. The ConvoKraft Deluge editor will be opened where you can code your business logic and save the script. Learn more about the Deluge editor from this page. You can test the changes parallely using Test this bot feature.

execution-function-page

Last Updated 2023-07-03 17:23:11 +0530 +0530