csml_interpreter 1.3.0-beta1

The CSML Interpreter is the official interpreter for the CSML programming language, a DSL designed to make it extremely easy to create rich and powerful chatbots.
docs.rs failed to build csml_interpreter-1.3.0-beta1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: csml_interpreter-1.11.2

CSML Language Interpreter

CSML logo

Functional diagram

diagram

Examples

Hello World

cargo run --example hello_world

Event

cargo run --example event

Metadata

cargo run --example metadata

Memory

cargo run --example memory

Quick Start run it yourself

requires Rust version 1.41.

use csml_interpreter::data::csml_bot::CsmlBot;
use csml_interpreter::data::csml_flow::CsmlFlow;
use csml_interpreter::data::event::Event;
use csml_interpreter::data::ContextJson;
use csml_interpreter::interpret;
use csml_interpreter::validate_bot;

const DEFAULT_ID_NAME: &str = "id";
const DEFAULT_FLOW_NAME: &str = "flow";
const DEFAULT_STEP_NAME: &str = "start";
const DEFAULT_BOT_NAME: &str = "my_bot";

////////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTION
////////////////////////////////////////////////////////////////////////////////

fn main() {
    let content = std::fs::read_to_string("./hello_world.csml").unwrap();

    // Create a CsmlFlow
    let flow = CsmlFlow::new(
        DEFAULT_ID_NAME,
        DEFAULT_FLOW_NAME,
        &content,
        Vec::default()
    );

    // Create a CsmlBot
    let bot = CsmlBot::new(
        DEFAULT_ID_NAME,
        DEFAULT_BOT_NAME,
        None,
        vec![flow],
        None,
        None,
        DEFAULT_FLOW_NAME,
    );

    // Create an Event
    let event = Event::default();

    // Create a Context
    let context = ContextJson::new(
        serde_json::json!({}),
        serde_json::json!({}),
        None,
        None,
        DEFAULT_STEP_NAME,
        DEFAULT_FLOW_NAME,
    );

    // Run interpreter
    let result = validate_bot(bot.to_owned());

    if result.errors.is_some() {
        dbg!(result.errors);
        return;
    }
    if result.warnings.is_some() {
        dbg!(result.warnings);
    }

    dbg!(interpret(bot, context, event, None));
}