ServisBOT ai Workers

Type: NLP Worker

ServisBOT ai is a worker type that does not use any third party services, it’s all handled internally. It is designed to quickly publish bots with low latency responses. Use the Starter Blueprint to get a quick bot setup.

Creating a SerisBOT ai worker though the cli.

Save this json to a file and create a worker using the cli command sb-cli worker create file.json

Fields

  • NluConfidenceThresholdOverride [Optional] You can use this as an override of the returned detected intent confidence. If this value is higher than that returned from the nlu provider it will change the response to be a fallback, this value defaults to 0.
  • Language [Optional] [Defaults to en] - Allows training of a bot in different languages. Any language supported by ServiceBOT, is supported here.
{
  "Data": {
    "NluConfiguration": {
      "NluConfidenceThresholdOverride": 0.8,
      "Language": "en"
    },
    "NluType": "ServisBOT"
  },
  "Organization": "my-org",
  "Config": {
    "Avatar": "default-bot"
  },
  "Enabled": true,
  "Description": "An amazing ServisBOT Worker",
  "Type": "nlp-worker",
  "Name": "exampleServisBOT",
  "Status": "published",
}

That’s right no configuration required. Once you have created the worker using the CLI, it will return an ID for you. You need to then update/create a bot with this worker.

{
  "Name": "exampleBot",
  "Workers": [
    {
      "Type": "nlp-worker",
      "Id": "new-id"
    }
  ]
}

Onces the worker is assigned to a bot, simply start adding Intents and publish your bot.

Dialog State Management

When an intent is hit we store that intent name and the timestamp in the users context, in the DialogStateManagement section under StateHistory. An example of what that might look like is this

{
  "state": {
    "history": ["cake", "coffee","coffee"]
  }
}

Conditional Botnet Actions

The NLP Worker supports execution of conditional botnet actions. An example is:

{
    "type": "message",
    "condition": "state.history.includes('apples')",
    "value": "You already asked me that, the answer is still no, don't you have something better to be doing?"
}

If a conditional errors during evaluation an bot-log exception will be visible.

The conditional can be any valid javascript and the current context is available during evaluation.

Custom Entities

The NLP Worker supports detecting custom entities, based on a definition of your chosing. The entities should be added the EntityStore key as array of custom entities. For example:

{
  "Data": {
    "EntityStore": [
      {
        "Config": {
          "LeftWord": "at",
          "RightWord": "pm"
        },
        "Lang": "en",
        "Name": "pmTime",
        "Type": "Between"
      }
    ],
    "NluConfiguration": {
      //some Nlu configuration
    },
    "NluType": "Lex"
  }
}

Custom entities can take the following forms:

Regex

The utterance will be matched against some regex string to be detected as an entity of Name

      {
        "Config": [
          "/\\d{4}[ -]?\\d{4}[ -]?\\d{4}[ -]?\\d{4}|\\d{4}[ -]?\\d{6}[ -]?\\d{4}\\d?/g"
        ],
        "Lang": "en",
        "Name": "creditcard",
        "Type": "Regex"
      }

If detected, the entity will be added to the state’s entities array. The sourceText field will contain what the user typed in the entity’s position and the entity field will contain the name of the entity, in this case “creditcard”.

#OptionText The utterance will be matched against a number of options, and if it does it will be detected as an entity of Name

      {
        "Config": [
          "Amber", //the first value in the array will be what the entity's option evaluates to
          "amber",
          "#ffbf00",
          "ffbf00"
        ],
        "Lang": "en",
        "Name": "color_amber",
        "Type": "OptionText"
      }

If detected, the entity will be added to the state’s entities array. The sourceText field will contain what the user typed in the entity’s position, the option field will contain the first element of the array in config, and the entity field will contain the name of the entity, in this case “color_amber”.

#Between The utterance will be checked to see if it is between two words, to be detected as an entity of Name

{
        "Config": {
          "LeftWord": "left",
          "RightWord": "right"
        },
        "Lang": "en",
        "Name": "betweener",
        "Type": "Between"
}

If detected, the entity will be added to the state’s entities array. The sourceText field will contain what the user typed in the entity’s position and the entity field will contain the name of the entity, in this case “betweener”.

Values available in condition sandbox & fulfillment context

  • state
    • state.history - A history of previous intents hit structured as an array of string values e.g [‘intent1’,‘intent2’]
    • state.entities - An array of objects forming detected entities by NLP.js
      • These entities take the form of:
      {
        start: 0,
        end: 25,
        len: 26,
        accuracy: 0.95,
        sourceText: 'email@servisbot.com',
        utteranceText: 'email@servisbot.com',
        entity: 'email',
        resolution: { value: 'email@servisbot.com' }
      }
      
      • The following entities can be detected:
        1. email
        2. hashtag
        3. number
        4. date
        5. ip
        6. url
        7. phonenumber
    • state.input - Contains information about the users input
      • state.input.language - the language we have detected from the browser
      • state.input.isMobile - a boolean for whether or not the user is on mobile
      • state.input.utteranceText - the utterance the user send int
  • user - Empty object
  • data - Empty object

Disambiguation

Disambiguation is supported within the NLP worker via the following configuration.

{
  "Data": {
    "NluConfiguration": {
      "DisambiguationConfig": {
        "DisambiguationMessage": "Sorry I did not understand that, please select one of the following options", 
        "AmbiguityDistance": 0.7,
        "MaxOptions": 5,
        "UserSelectedNoneActions": [
          {
            "Type": "message",
            "Value": "You have selected none."
          },
          {
            "Type": "markup",
            "Value": "<TimelineMessage><TextMsg>Please ask me another question</TextMsg></TimelineMessage>"
          }
        ]
      }
    }
  }
}
  • DisambiguationMessage - The message used to prompt the user to select an intent
  • AmbiguityDistance - The distance between the confidence values to determine if the the response from the NLU engine is ambiguous, e.g. with an AmbiguityDistance of 0.2 and a confidence score of .8 on intent A and a confidence score of 0.7 on intent B, the result is considered ambiguous.
  • MaxOptions - The max number of options to present to the user if classification confidence of multiple intens are within the AmbiguityDistance
  • UserSelectedNoneActions - An array of botnet actions to execute if the user select none of the presented ambiguous intents. These are also executed if the user types a response to the bot.