0.1.3 • Published 2 years ago

bot-framework-mutant-whats-adapter v0.1.3

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Mutant Whats Adapter to Microsoft Bot Framework

Mutant Whats é a solução da Mutant de integração com o WhatsApp Business API. Este pacote é um adapter para integração do botframework e o MutantWhats.

Para usá, é necessário apenas importá-la no arquivo principal

const { MutantWhatsAdapter } = require('bot-framework-mutant-whats-adapter')

// [...]

const mutantWhatsAdapter = new MutantWhatsAdapter({
    id: 'ID do bot',
    name: 'Nome do bot'
})

// [...]

const router = express.Router()

router.post('/start-conversation', async (req, res) => {
    log.info('/start-conversation', { request_body: req.body })

    try {
        await mutantWhatsAdapter.processActivity(req, res, "start-conversation", async (context) => {
            await bot.run(context)
        })
    } catch (e) {
        log.error(e)
    }
})

router.post('/message', async (req, res) => {
    log.info('/message', { request_body: req.body })

    try {
        await mutantWhatsAdapter.processActivity(req, res, "message", async (context) => {
            await bot.run(context)
        })
    } catch (e) {
        log.error(e)
    }
})