npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

prodap-chatbot-domain

v1.14.12

Published

Classes utilizadas na resposta de todas as Intents do Assistente Virtual

Downloads

495

Readme

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.