1.22.1 • Published 4 months ago

prodap-chatbot-domain v1.22.1

Weekly downloads
82
License
MIT
Repository
gitlab
Last release
4 months ago

Prodap Chatbot Domain

Classes de domínio responsáveis por montar uma gramática rica e padronizada para o Chatbot da Prodap. Veja abaixo como criar uma mensagem simples para o Chatbot:

const result = new Dialog('start-day')
result.add(
    new SystemText(
        'Sou Loris, sua Assistente Pessoal, e vou acompanhar a rotina da fazenda junto com você!'
    )
)

res.json(result)

O próximo exemplo cria uma mensagem complexa:

const result = new Dialog('start-day')
result
    .add(
        new PlainText(
            'Sou Loris, sua Assistente Pessoal, e vou acompanhar a rotina da fazenda junto com você!'
        )
    )
    .add(new PlainText('Olá eu sou a Loris! Vou te ajudar com algumas dicas.'))
    .add(new PlainText('blá blá blá'))
    .add(
        new Menu(
            'Gostaria de visualizar alguns indicadores?',
            new HttpAction({ label: '👍 Sim', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: '👎 Não', url: 'http://teste.com/next?value=no' }),
            new HttpAction({ label: '👎 Cancelar', url: 'http://teste.com/next?value=cancel' }),
            new DialogAction({ label: 'Encerrar', dialog: new Dialog().add(new PlainText('Ok então. Até mais')) })
        )
    )

res.json(result)

Este exemplo mostra como criar uma mensagem com um gráfico de Pizza:

const result = new Dialog('chart-intent')

result.add(
    new PieChart('Acompanhamento e Vistorias', 'Maio/2020', 'Vistoria dos Lotes', 'TOTAL: 46 Lotes')
        .addData(
            {
                label: 'Lotes vistoriados nos ultimos 3 dias: 72% - 33 lotes',
                value: 33,
                color: 'green',
            },
            {
                label: 'Lotes vistoriados nos ultimos 7 dias: 12% - 6 lotes',
                value: 6,
                color: 'orange',
            },
            {
                label: 'Lotes vistoriados há mais de uma semana: 16% - 7 lotes',
                value: 33,
                color: 'red',
            }
        )
        .addAction(new HttpAction({ label: 'Detalhar informações', 'https://action.detail.pie'))
)

res.json(result)

Este exemplo mostra como criar um Card, que e composto de listas de objetos:

       const result = new Dialog('CardListActions')

    let cardProps: CardListProps = {
        cardListProps: {
            title: 'Parcialmente vistoriados nos últimos 3 dias',
            subtitle: 'MÓDULOS E PASTOS AFETADOS',
            tooltip: 'Clique no módulo / pasto para ver os retiros associados',
        } as CardProps,
    }

    result.add(
        new CardList(cardProps).addList(
            new HttpAction({ label: 'MOD. QUIXUIO RIO GRANDE DO SUL', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'MOD. FRENTE CASA DA SEDE', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'MOD. QUICUIO DA MATA', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'MOD. QUICUIO GRANDE GAMELEIRA', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'MOD. MATA AMARELA', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'Pasto Canto', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'Pasto Fundo do curral', url: 'http://teste.com/next?value=no' }),
            new HttpAction({ label: 'Pasto Alegria', url: 'http://teste.com/next?value=no' }),
            new HttpAction({ label: 'Pasto Esperança', url: 'http://teste.com/next?value=no' }),
            new HttpAction({ label: 'Pasto Lança Curta', url: 'http://teste.com/next?value=no' }),
            new HttpAction({ label: 'Pasto Lima Limão', url: 'http://teste.com/next?value=no' })
        )
    )

    cardProps = {
        cardListProps: {
            title: 'Lotes vistoriados há mais de uma semana',
            subtitle: 'MÓDULOS E PASTOS AFETADOS',
            tooltip: 'Clique no módulo / pasto para ver os retiros associados',
        } as CardProps,
    }

    result.add(
        new CardList(cardProps).addList(
            new HttpAction({ label: 'MOD. QUIXUIO RIO GRANDE DO SUL', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'MOD. FRENTE CASA DA SEDE', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'MOD. QUICUIO DA MATA', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'MOD. QUICUIO GRANDE GAMELEIRA', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'MOD. MATA AMARELA', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'Pasto Canto', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'Pasto Fundo do curral', url: 'http://teste.com/next?value=no' })
        )
    )

Este exemplo mostra como criar um Gráfico de Barras:

let result = new Dialog('BarChart')

result.add(
    new BarChart(
        'Tábuas do barril x Vistorias',
        'Maio/2020',
        '% de itens acompanhados nos últimos 7 dias',
        'TOTAL: 29 Lotes',
        DataTypes.NUMBER
    )
        .addData(
            {
                label: 'Aguada',
                value: 33,
            },
            {
                label: 'Rebanho',
                value: 6,
            },
            {
                label: 'Altura Pasto',
                value: 33,
            }
        )
        .addRule(
            {
                valMin: 0,
                valMax: 39,
                label: 'Inferior à 40%',
                color: 'red',
            },
            {
                valMin: 40,
                valMax: 54,
                label: '40% à 55%',
                color: 'orange',
            },
            {
                valMin: 55,
                valMax: 100,
                label: 'Inferior à 40%',
                color: 'green',
            }
        )
        .addAction(new HttpAction({ label: 'Detalhar informações', 'https://action.detail.bar' }))
)

Este exemplo mostra como criar CardListOfList:

const result = new Dialog('CardListOfList')

result.add(
    new CardListOfList({
        title: 'Módulos/ pastos NÃO VISTORIADOS nos últimos 7 dias',
        subtitle: 'MÓDULOS E PASTOS AFETADOS',
        tooltip: 'Clique no módulo / pasto para ver os retiros associados',
    }).addCardList(
        new CardList({
            title: 'RETIRO A',
        }).addList(
            new HttpAction({ label: 'MOD. QUIXUIO RIO GRANDE DO SUL', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'MOD. FRENTE CASA DA SEDE', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'MOD. QUICUIO DA MATA', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'MOD. QUICUIO GRANDE GAMELEIRA', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'MOD. MATA AMARELA', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'Pasto Canto', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'Pasto Fundo do curral', url: 'http://teste.com/next?value=no' }),
            new HttpAction({ label: 'Pasto Alegria', url: 'http://teste.com/next?value=no' }),
            new HttpAction({ label: 'Pasto Esperança', url: 'http://teste.com/next?value=no' }),
            new HttpAction({ label: 'Pasto Lança Curta', url: 'http://teste.com/next?value=no' }),
            new HttpAction({ label: 'Pasto Lima Limão', url: 'http://teste.com/next?value=no' })
        ),
        new CardList({
            title: 'RETIRO B',
        }).addList(
            new HttpAction({ label: 'MOD. QUIXUIO RIO GRANDE DO SUL', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'MOD. FRENTE CASA DA SEDE', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'MOD. QUICUIO DA MATA', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'MOD. QUICUIO GRANDE GAMELEIRA', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'MOD. MATA AMARELA', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'Pasto Canto', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'Pasto Fundo do curral', url: 'http://teste.com/next?value=no' }),
            new HttpAction({ label: 'Pasto Alegria', url: 'http://teste.com/next?value=no' }),
            new HttpAction({ label: 'Pasto Esperança', url: 'http://teste.com/next?value=no' }),
            new HttpAction({ label: 'Pasto Lança Curta', url: 'http://teste.com/next?value=no' }),
            new HttpAction({ label: 'Pasto Lima Limão', url: 'http://teste.com/next?value=no' })
        ),
        new CardList({
            title: 'RETIRO C',
        }).addList(
            new HttpAction({ label: 'MOD. QUIXUIO RIO GRANDE DO SUL', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'MOD. FRENTE CASA DA SEDE', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'MOD. QUICUIO DA MATA', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'MOD. QUICUIO GRANDE GAMELEIRA', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'MOD. MATA AMARELA', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'Pasto Canto', url: 'http://teste.com/next?value=yes' }),
            new HttpAction({ label: 'Pasto Fundo do curral', url: 'http://teste.com/next?value=no' }),
            new HttpAction({ label: 'Pasto Alegria', url: 'http://teste.com/next?value=no' }),
            new HttpAction({ label: 'Pasto Esperança', url: 'http://teste.com/next?value=no' }),
            new HttpAction({ label: 'Pasto Lança Curta', url: 'http://teste.com/next?value=no' }),
            new HttpAction({ label: 'Pasto Lima Limão', url: 'http://teste.com/next?value=no' })
        )
    )
)

Instalação

Esta é uma biblioteca do Node.js disponível por meio do registro npm . Antes de instalar, baixe e instale Node.js. É necessário Node.js 12.18.2 ou superior.

Se este for um projeto totalmente novo, certifique-se de criar um package.json primeiro com o comando npm init.

A instalação é feita usando o comando npm install:

$ npm install prodap-chatbot-domain

Vantagens:

  • Padronização das respostas
  • Uso do padrão de design Fluent Interface para a construção do retorno
  • Uma gramática rica, que permite montar diálogos complexos para que sistemas de Chat interpretem.
1.18.9

8 months ago

1.18.8

8 months ago

1.21.0

6 months ago

1.21.4

6 months ago

1.21.5

5 months ago

1.21.2

6 months ago

1.21.3

6 months ago

1.21.8

5 months ago

1.21.6

5 months ago

1.21.7

5 months ago

1.19.0

8 months ago

1.19.2

7 months ago

1.19.1

7 months ago

1.22.0

5 months ago

1.22.1

4 months ago

1.20.1

6 months ago

1.20.2

6 months ago

1.20.0

7 months ago

1.18.12

8 months ago

1.18.11

8 months ago

1.18.10

8 months ago

1.18.15

8 months ago

1.18.14

8 months ago

1.18.13

8 months ago

1.18.7

9 months ago

1.18.1

9 months ago

1.18.0

9 months ago

1.18.5

9 months ago

1.18.4

9 months ago

1.18.3

9 months ago

1.18.2

9 months ago

1.18.6

9 months ago

1.16.3

11 months ago

1.16.5

10 months ago

1.16.4

10 months ago

1.17.2

10 months ago

1.17.1

10 months ago

1.17.0

10 months ago

1.17.5

9 months ago

1.17.4

10 months ago

1.17.3

10 months ago

1.15.0

12 months ago

1.15.3

12 months ago

1.15.2

12 months ago

1.15.1

12 months ago

1.16.2

11 months ago

1.16.1

11 months ago

1.16.0

11 months ago

1.14.12

1 year ago

1.14.11

1 year ago

1.14.10

1 year ago

1.14.9

1 year ago

1.14.8

1 year ago

1.14.7

1 year ago

1.14.6

1 year ago

1.14.5

1 year ago

1.14.4

1 year ago

1.14.3

1 year ago

1.14.2

1 year ago

1.14.1

2 years ago

1.14.0

2 years ago

1.12.14

2 years ago

1.12.13

2 years ago

1.13.1

2 years ago

1.13.0

2 years ago

1.12.12

2 years ago

1.12.11

2 years ago

1.10.9

2 years ago

1.10.8

2 years ago

1.10.7

2 years ago

1.12.3

2 years ago

1.12.2

2 years ago

1.12.1

2 years ago

1.12.0

2 years ago

1.12.7

2 years ago

1.12.6

2 years ago

1.12.5

2 years ago

1.12.4

2 years ago

1.12.9

2 years ago

1.12.8

2 years ago

1.12.10

2 years ago

1.11.0

2 years ago

1.10.13

2 years ago

1.10.11

2 years ago

1.10.12

2 years ago

1.10.10

2 years ago

1.10.5

2 years ago

1.10.4

2 years ago

1.10.3

2 years ago

1.10.2

2 years ago

1.10.6

2 years ago

1.10.1

2 years ago

1.10.0

2 years ago

1.6.1

2 years ago

1.6.0

2 years ago

1.9.1

2 years ago

1.5.5

2 years ago

1.9.0

2 years ago

1.5.4

2 years ago

1.5.3

2 years ago

1.8.1

2 years ago

1.8.0

2 years ago

1.5.9

2 years ago

1.5.8

2 years ago

1.9.3

2 years ago

1.5.7

2 years ago

1.9.2

2 years ago

1.5.6

2 years ago

1.7.0

2 years ago

1.5.2

3 years ago

1.5.1

3 years ago

1.5.0

3 years ago

1.4.0

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.1.0

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.2

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.5.70

3 years ago

0.5.71

3 years ago

0.5.69

4 years ago

0.5.68

4 years ago

0.5.65

4 years ago

0.5.66

4 years ago

0.5.63

4 years ago

0.5.64

4 years ago

0.5.67

4 years ago

0.5.61

4 years ago

0.5.62

4 years ago

0.5.60

4 years ago

0.5.59

4 years ago

0.5.58

4 years ago

0.5.57

4 years ago

0.5.56

4 years ago

0.5.55

4 years ago

0.5.54

4 years ago

0.5.52

4 years ago

0.5.53

4 years ago

0.5.51

4 years ago

0.5.50

4 years ago

0.5.49

4 years ago

0.5.48

4 years ago

0.5.47

4 years ago

0.5.44

4 years ago

0.5.45

4 years ago

0.5.46

4 years ago

0.5.43

5 years ago

0.5.42

5 years ago

0.5.41

5 years ago

0.5.40

5 years ago

0.5.38

5 years ago

0.5.39

5 years ago

0.5.37

5 years ago

0.5.33

5 years ago

0.5.36

5 years ago

0.5.34

5 years ago

0.5.35

5 years ago

0.5.32

5 years ago

0.5.31

5 years ago

0.5.30

5 years ago

0.5.29

5 years ago

0.5.28

5 years ago

0.5.27

5 years ago

0.5.26

5 years ago

0.5.25

5 years ago

0.5.24

5 years ago

0.5.23

5 years ago

0.5.22

5 years ago

0.5.21

5 years ago

0.5.18

5 years ago

0.5.19

5 years ago

0.5.16

5 years ago

0.5.20

5 years ago

0.5.14

5 years ago

0.5.15

5 years ago

0.5.13

5 years ago

0.5.12

5 years ago

0.5.11

5 years ago

0.5.10

5 years ago

0.5.9

5 years ago

0.5.8

5 years ago

0.5.7

5 years ago

0.5.6

5 years ago

0.5.5

5 years ago

0.5.4

5 years ago

0.5.3

5 years ago

0.5.2

5 years ago

0.4.9

5 years ago

0.5.0

5 years ago

0.5.1

5 years ago

0.4.8

5 years ago

0.4.7

5 years ago

0.4.6

5 years ago

0.4.5

5 years ago

0.4.4

5 years ago

0.4.3

5 years ago

0.4.1

5 years ago

0.4.2

5 years ago

0.3.2

5 years ago

0.4.0

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.1

5 years ago