brq-cr / wiz-js

🤖 Reactive framework for bot development

Home Page:http://wiz.godel.la

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

wiz-js

Reactive framework for bot development

Warning this is for experimental use only

Install

npm install wiz-js --save

Example of use

const { Wiz, Action, Context, Provider } = require('wiz-js');

function setActionContext(ctx, next) {
    ctx.pushAction('HELLO_WORLD');
    next();
}

class MyProvider extends Provider {
    constructor(bar) {
        super();
        this.foo = bar;
    }

    someMethod() {
        return this.foo;
    }
}

const HELLO_WORLD = new Action([
    {
        rule: ctx => ctx.of('action:HELLO_WORLD'),
        action: (ctx, { MyProvider }) => {
            console.log(MyProvider.someMethod(), MyProvider.context());
            return `Hello ${ctx.input()}`;
        },
    },
]);

const wiz = new Wiz({
    middlewares: [
        setActionContext,
    ],
    actions: [
        HELLO_WORLD,
    ],
    providers: [
        new MyProvider('MyConfigurationValues-1283628192hd82'),
    ],
});

wiz.listen(new Context({
    input: 'world',
})).subscribe((botAnswer) => {
    console.log(botAnswer);
});

About

🤖 Reactive framework for bot development

http://wiz.godel.la

License:MIT License


Languages

Language:JavaScript 100.0%