Skip to main content

A solution for chatbot constructors to identify problems in flow structure.

Project description

Blip Flow Analysis

Blip Flow Analysis provides a solution for chatbot constructors to identify problems in flow structure that can be originated from bad structuring or poor organization.

Installation

Use pip to install:

pip install blip_flowanalysis

Usage

Missing Trackings analysis

Using the MissingTrackigns analyser:

import blip_flowanalysis as bfa

# Replace __chatbot_as_json__ parameter by your json bot.
bot_flow = bfa.Flow(__chatbot_as_json__)
analyser = bfa.MissingTrackings(minimum=1)

# Return `True` if amount of Trackings is above minimum, `False` otherwise.
print(analyser.analyse(bot_flow)) 

Process HTTP Return Validation analysis

Two types of validation are performed for each HTTP request in the chatbot flow:

  • Next action validation: check if request is validated by the action immediately after it.
  • Outputs validation: check if the request is validated by the outputs of the request's state.

The HTTP request validation process has three possible outcomes:

  • status validation: validation found using the request's status variable (best practice);
  • body validation: validation found using the request's body variable (warning);
  • no validation: validation wasn't found using either status or body variable (warning).

Using the ProcessHTTPReturnValidation analyser:

import blip_flowanalysis as bfa

# Replace __chatbot_as_json__ parameter by your json bot.
bot_flow = bfa.Flow(__chatbot_as_json__)
http_analyser = bfa.ProcessHTTPReturnValidation()

# Return validation report with "summary" and "warnings".
validation_report = http_analyser.analyse(bot_flow)

print(validation_report)

The structure of the validation report is presented bellow.

{
    "summary":
    {
        "total": number of HTTP requests found,
        "status validation": number of requests with validation of status variable,
        "body validation": number of requests with validation of body variable,
        "no validation": number of requests without validation of either status or body variable
    },
    "warnings":
    [
        {
            "state id": state id in which the request action is located,
            "action type": either "inputActions" or "outputActions",
            "status variable": status variable name,
            "body variable": body variable name,
            "validation": either "body validation" or "no validation"
        }
    ]
}

Long Scripts analysis

Using the LongScript analyser:

# import json
import blip_flowanalysis as bfa

bot_json = str("Your chatbot json here.")
# bot_json = json.load("or your chatbot json file here")

bot_flow = bfa.Flow(bot_json)
ls_analyser = bfa.LongScript()

# Report with "summary" and "details" with long scripts detections.
report = ls_analyser.analyse(bot_flow)

print(report)

Output is like:

{
    "summary": {
        "scripts count": n_scripts,
        "scripts too long": n_long_scripts,
        "states count": n_states,
        "states with too long scripts": n_irregular_states
    },
    "details": [
        {
            "state id": state_id,  # State ID on bot flow.
            "state name": state_name,  # State name on bot flow.
            "io action": io_action,  # Any of inputActions and outputActions.
            "action number": action_number,  # Action position on actions list.
            "script": script,  # Script.
            "chars": length,  # Code characters quantity.
            "lines": lines,  # Not blank code lines quantity.
            "functions": functions,  # Top level functions quantity.
            "commands": commands,  # Commands quantity.
            "lines by commands": lines_by_commands,  # Lines commands ratio.
            "causes": cause  # Explain why this script was detected.
        },
        ...
    ]
}

Duplicated Paths analysis

Using the DuplicatedPaths analyser:

# import json
import blip_flowanalysis as bfa

bot_json = str("Your chatbot json here.")
# bot_json = json.load("or your chatbot json file here")

bot_flow = bfa.Flow(bot_json)
dp_analyser = bfa.DuplicatedPaths()

# Report with "summary" and "details" with long scripts detections.
report = dp_analyser.analyse(bot_flow)

print(report)

Output is like:

{
    "summary": {
        "pairs of duplicated paths": n_duplicated_paths,
        "states count": n_states,
        "states on duplicated paths": n_irregular_states
    },
    "details": [
        {
            "levels quantity": n_levels,  # Quantity of levels on path
            "states quantity": n_states_on_path,  # Quantity of states on path
            "root 0": {"id": state_id, "name": state_name},  # State as root on path 0
            "root 1": {"id": state_id, "name": state_name},  # State as root on path 1
            "path 0": {  # Path 0
                "level 0": [  # First level on path 0
                    {"id": state_id, "name": state_name},  # States on level 0 on path 0
                    ...  # Other states
                ],
                ...  # Other levels
            },
            "path 1": {  # Path 1
                "level 0": [  # First level on path 1
                    {"id": state_id, "name": state_name},  # States on level 0 on path 1
                    ...  # Other states
                ],
                ...  # Other levels
            },
        },
        ...
    ]
}

Author

Take Data&Analytics Research

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

blip_flowanalysis-0.5.0.tar.gz (26.0 kB view hashes)

Uploaded Source

Built Distribution

blip_flowanalysis-0.5.0-py3-none-any.whl (36.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page