Smart Responses

Automatically analyze and answer questions posted within tickets

The SmartResponses feature allows your bot to automatically respond to specific phrases in messages or during ticket creation. This helps provide quick and relevant information without manual intervention.

How It Works

When a user submits a message or a modal input, the bot scans the input for predefined phrases. If a match is found based on the configured criteria, the bot responds automatically with a specified message or embed. The matching process can include advanced analysis like synonym recognition and contextual understanding.

Configuration Options

Phrases

Each phrase entry specifies a phrase to detect, the response to give, and how closely a message must match the phrase to trigger the response.

ConfigurationDescriptionExample

Phrase

The exact phrase or question the bot should look for.

"How do I setup Mongo?"

Response

The message the bot should send when the phrase is detected.

"Please follow this guide - https://docs.drakodevelopment.net/misc/mongodb-setup"

MatchPercent

The similarity threshold for triggering a response. A higher value means a closer match is required.

0.75

Type

The format of the response. Can be TEXT for a text message or EMBED for an embed message.

"TEXT"

Note: The MatchPercent can be between 0.00 and 1.00, with 1.00 meaning 100% of the message needs to match. It is suggested to keep MatchPercent around 0.80-0.85 to reduce false flags.

Advanced Analysis

ConfigurationDescriptionExample

SynonymThreshold

Controls how the bot recognizes words with similar meanings.

0.65

ContextualAnalysis

Allows the bot to understand the meaning of a phrase based on the context it is used in.

true

Hint: Set SynonymThreshold to a value between 0.00 and 1.00. A lower threshold makes the bot more flexible in recognizing synonyms, while a higher threshold makes it stricter. For better performance, a value around 0.60-0.70 is recommended.

Example Usage

If a user submits a ticket with the message, "I can't set up MongoDB," the bot can understand this in the context of database setup issues and respond accurately, even if the exact phrase "setup Mongo" isn't used. By enabling ContextualAnalysis, the bot can better understand and respond to varied ways users might phrase their questions or problems.

Example Configurations

No Role Requirement

Below is an example configuration showing phrases and their responses without role requirements:

SmartResponses:
  Enabled: true
  Phrases:
    MongoSetup: 
      Phrase: 
        - "How do I setup Mongo"
        - "How can I configure MongoDB"
        - "Set up MongoDB"
        - "Install MongoDB"
      MatchPercent: 0.85
      Type: "TEXT"
      Response: "Please follow this guide - https://docs.drakodevelopment.net/misc/mongodb-setup"
      AdvancedAnalysis:
        SynonymThreshold: 0.70
        ContextualAnalysis: true

Role Requirement

Below is an example configuration showing phrases and their responses with role requirements:

SmartResponses:
  Enabled: true
  Phrases:
    TicketSetup: 
      Phrase: 
        - "How do I setup the ticket system?"
        - "How can I configure the ticket system?"
        - "Set up ticketing system"
        - "Install ticket system"
      MatchPercent: 0.85
      Type: "TEXT"
      AdvancedAnalysis:
        SynonymThreshold: 0.75
        ContextualAnalysis: true
      Roles: ["ROLE_ID1", "ROLE_ID2"]
      HasRoleResponse: "Hey, please use this guide for setting up the ticket system - https://docs.drakodevelopment.net/drako-bot/ticket-system"
      NoRoleResponse: "Please use this guide for setting up the ticket system - https://docs.drakodevelopment.net/drako-bot/ticket-system"

Embed Example

Below is an example configuration showing phrases and their responses with embeds:

SmartResponses:
  Enabled: true
  Phrases:
    RefundPolicy: 
      Phrase: 
        - "What is the refund policy?"
        - "Where can I find the refund policy?" 
        - "Refund information"
        - "How to get a refund"
      MatchPercent: 0.80
      Type: "EMBED"
      Embed:
        Title: "Refund Policy"
        Description:
          - "Our refund policy allows for returns within 30 days of purchase."
          - "You can find the complete policy on our website."
        Footer:
          Text: "Drako Development | Smart Responses"
          Icon: "https://i.imgur.com/w5XxKpc.png"
        Color: "#ADD8E6"
      AdvancedAnalysis:
        SynonymThreshold: 0.70
        ContextualAnalysis: true
SmartResponses:
  Enabled: true
  Phrases:
    DrakoDevelopment: 
      Phrase: 
        - "What is Drako Development?"
        - "Who is Drako Development?" 
        - "Information about Drako Development"
        - "Details about Drako Development"
      MatchPercent: 0.80
      Type: "EMBED"
      Roles: ["ROLE_ID1", "ROLE_ID2"]
      HasRoleEmbed:
        Title: "Drako Development"
        Description:
          - "Drako Development is the creator of Drako Bot."
        Footer:
          Text: "Drako Development | Smart Responses"
          Icon: "https://i.imgur.com/w5XxKpc.png"
        Color: "#FFD700"
      NoRoleEmbed:
        Title: "Standard Refund Policy"
        Description:
          - "Drako Development is the creator of Drako Bot."
          - "Non Customer Response"
        Footer:
          Text: "Drako Development | Smart Responses"
          Icon: "https://i.imgur.com/w5XxKpc.png"
        Color: "#ADD8E6"
      AdvancedAnalysis:
        SynonymThreshold: 0.70
        ContextualAnalysis: true

Note: You can set HasRoleResponse or NoRoleResponse to an empty string "" if you do not want to send any message when a role-specific response is triggered.

Setting Up SmartResponses

  1. Identify Common Queries: List the common questions or phrases users might ask.

  2. Define Responses: For each phrase, create a clear, helpful response. Decide if it should be a simple text message or an informative embed.

  3. Configure MatchPercent: Set the similarity threshold. Start with 0.75 and adjust based on accuracy.

  4. Enable Advanced Analysis (Optional): Use SynonymThreshold and ContextualAnalysis for better matching accuracy.

Advanced Usage: ErrorPatterns

IMPORTANT: Do not use ErrorPatterns if you do not understand Regex.

The ErrorPatterns feature allows advanced users to configure specific error patterns and responses for their bots. This is useful for automatically diagnosing and responding to common errors in the bot's runtime environment.

Configuration Options

Each error pattern entry specifies a regex pattern to detect, and the response message.

Example Configurations

ErrorPatterns:
  FileNotFoundError:
    Pattern: "Error: Cannot find module '(.*)'\\s*Require stack:"
    Type: "TEXT"
    Response: "It seems you are missing the file '{1}'. Please ensure that the file is present in the folder."
  
  ModuleNotFoundError:
    Pattern: "Error: Cannot find module '(.*)'"
    Type: "TEXT"
    Response: "It seems you are missing the module '{1}'. You can install it using `npm install {1}`."
  
  NPMInstallError:
    Pattern: "Error: The specified module could not be found\\.\\s*\\\\\\?.*\\.(node)"
    Type: "TEXT"
    Response: "It seems you are missing a node module. Please try running `npm install` to ensure all packages are installed correctly."
  
  SyntaxError:
    Pattern: "SyntaxError: (.*)"
    Type: "TEXT"
    Response: "There is a syntax error: '{1}'. Please review your code for any syntax mistakes."
  
  EADDRINUSEError:
    Pattern: "Error: listen EADDRINUSE: address already in use (.*):(.*)"
    Type: "TEXT"
    Response: "It looks like the port '{2}' is already in use. This usually means you have two instances of the bot running. Please check and stop any other running bots or change the port number in your configuration."
  
  SpecifiedModuleNotFoundError:
    Pattern: "Error: The specified module could not be found\\."
    Type: "TEXT"
    Response: "It seems you are missing a required node module. Please try running `npm install` to ensure all packages are installed."

Creating Regex Patterns

  1. Identify the Error Message: Look at the typical error messages you want to catch.

  2. Create the Regex Pattern: Write a regex pattern that matches the error message. Use capturing groups (.*) to capture variable parts of the error message.

  3. Escape Special Characters: Escape special characters as needed.

  4. Test the Pattern: Make sure the regex pattern correctly matches the error messages.

Example Explanation

FileNotFoundError

  • Pattern: Error: Cannot find module '(.*)'\\s*Require stack:

  • Explanation: This pattern matches the error message when a module file is not found. It captures the missing module name.

  • Response: "It seems you are missing the file '{1}'. Please ensure that the file is present in the folder."

ModuleNotFoundError

  • Pattern: Error: Cannot find module '(.*)'

  • Explanation: This pattern matches the error message when a module is not found. It captures the missing module name.

  • Response: "It seems you are missing the module '{1}'. Please ensure that the module is installed. You can install it using npm install {1}."

NPMInstallError

  • Pattern: Error: The specified module could not be found\\.\\s*\\\\\\?.*\\.(node)

  • Explanation: This pattern matches the error message for missing node modules.

  • Response: "It seems you are missing a node module. Please try running npm install to ensure all packages are installed correctly."

SyntaxError

  • Pattern: SyntaxError: (.*)

  • Explanation: This pattern matches syntax error messages and captures the error description.

  • Response: "There is a syntax error: '{1}'. Please review your code for any syntax mistakes."

EADDRINUSEError

  • Pattern: Error: listen EADDRINUSE: address already in use (.*):(.*)

  • Explanation: This pattern matches the error message when an address is already in use and captures the address and port.

  • Response: "It looks like the port '{2}' is already in use. This usually means you have two instances of the bot running. Please check and stop any other running bots or change the port number in your configuration."

SpecifiedModuleNotFoundError

  • Pattern: Error: The specified module could not be found\\.

  • Explanation: This pattern matches a generic module not found error.

  • Response: "It seems you are missing a required node module. Please try running npm install to ensure all packages are installed."

Last updated