Javascript Functions

JavaScript function responses represent a unique and powerful feature in AI chatbots.

From e-commerce to travel, healthcare, and finance, you can address an array of use cases and provide valuable solutions to end users.

To navigate to set up JavaScript functions as Responses:

  1. Select between Condition Functions and Action Functions

Condition functions and Action functions refer to specific function types that allow your chatbot to evaluate conditions and perform actions accordingly.

These functions are used to create dynamic and context-aware responses.

Condition functions typically return a Boolean value (true or false) based on the evaluation. Common use cases for condition functions in AI chatbots include:

  • Intent Recognition: Checking the user's intent.

  • Context Awareness: Evaluating the conversation context.

  • Validation: Verifying user input to ensure it meets certain criteria or constraints.

  • Routing: Deciding which conversation path to follow based on specific conditions.

  • User Authentication: Checking user authentication/specific permissions to perform certain actions.

Action functions perform specific operations based on the outcome of condition functions or as part of the chatbot's response. These functions execute tasks, update data, or trigger external processes to fulfill the user's request or provide a response.

Common use cases for action functions in chatbots include:

  • Sending Messages: Sending text, images, files, or other media as responses to the user.

  • API Calls: Making API requests to external services or databases.

  • Database Operations: Storing or retrieving data from a database.

  • Form Submission: Handling form submissions or user input.

  • Calculations: Data processing.

  • Navigation: Redirecting users to specific sections or pages within the chatbot interface.

  1. Once you choose Condition from the template, the description and code sample is updated accordingly:

Depending upon the choice of condition (exists, equals, or matches regex) or action javascript response (enable, delete), test your function according to the conditions set up.

Exists: For example, if a user inquires about whether X exists on the menu, your bot will use the exist function to check.

Equals: For example, if a user inquires about software updates/weather updates/policy updates, your bot will use the equal function to check updates to the said database.

Matches Regex: For example, when your user introduces themselves with a certain name pattern, then your bot uses matches regex to compare name patterns and respond with the name in context.

Enable: For example, if your user requests your chatbot to enable weather forecasts or monthly email notifications for banking statements, then your bot responds with a respective feature enabling it.

Delete: Similar to the above use case, if the user requests to delete a specific file/associated account, then your bot responds with a respective feature deleting it.

Last updated