1.0.9 • Published 8 months ago

create-urban-bot v1.0.9

Weekly downloads
95
License
MIT
Repository
github
Last release
8 months ago

npm package Build

Urban Bot

Universal chatbot library based on React.

  • Declarative. You don't need to know any messenger API, just write simple react components.
  • Multiplatform. Write once, launch any messenger.
  • Reusable. Easy share logic between different chatbots or just use common parts.
  • Session. App renders unique for every chat, so just write your app as if it is client-side rendering.
  • Types. Full typescript support.

Platforms we are supporting

npm.ionpm.ionpm.io

Soon

npm.ionpm.ionpm.ionpm.io

Documentation

Installation

Please use our zero configuration starter.

Or install manually:

$ npm i react @urban-bot/core @urban-bot/telegram @urban-bot/facebook ...

Example

Hello, World!

import React from 'react';
import { render, Root, Text } from '@urban-bot/core';
import { UrbanBotTelegram } from '@urban-bot/telegram';

const bot = new UrbanBotTelegram({
    token: 'telegramToken',
    polling: true,
});

render(
    <Root bot={bot}>
        <Text>Hello, world!</Text>
    </Root>
);

With Router

npm.io npm.io

import React from 'react';
import { render, Route, Router, Root, Text, ButtonGroup, Button, useText } from '@urban-bot/core';
import { UrbanBotTelegram } from '@urban-bot/telegram';
import { UrbanBotSlack } from '@urban-bot/slack';

function Echo() {
    const [text, setText] = React.useState('Say something');

    useText(({ text }) => {
        setText(text);
    });

    return (
        <Text isNewMessageEveryRender>
            <i>{text}</i>
        </Text>
    );
}

function Counter() {
    const [count, setCount] = React.useState(0);

    const increment = () => setCount(count + 1);
    const decrement = () => setCount(count - 1);

    return (
        <ButtonGroup title={count}>
            <Button onClick={increment}>+1</Button>
            <Button onClick={decrement}>-1</Button>
        </ButtonGroup>
    );
}

function App() {
    return (
        <Router>
            <Route path="/echo">
                <Echo />
            </Route>
            <Route path="/counter">
                <Counter />
            </Route>
        </Router>
    );
}

render(
    <Root
        bot={
            new UrbanBotTelegram({
                token: telegramToken,
                polling: true,
            })
        }
    >
        <App />
    </Root>
);

render(
    <Root
        bot={
            new UrbanBotSlack({
                signingSecret: slackSigningSecret,
                token: slackToken,
            })
        }
    >
        <App />
    </Root>
);
1.0.9

8 months ago

1.0.7

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.2

1 year ago

1.0.3

1 year ago

1.0.1

2 years ago

1.0.0

2 years ago

1.0.0-alpha.2

2 years ago

1.0.0-alpha.1

2 years ago

1.0.0-alpha.0

2 years ago

0.3.9

2 years ago

0.3.6

2 years ago

0.3.5

2 years ago

0.3.8

2 years ago

0.3.7

2 years ago

0.3.4

3 years ago

0.3.3

3 years ago

0.3.2

3 years ago

0.3.0

3 years ago

0.3.1

3 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.12

4 years ago

0.1.11

4 years ago

0.1.10

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.13

4 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.3-1

5 years ago

0.0.3

5 years ago

0.0.6

5 years ago

0.0.2-1

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago