npm.io
0.1.3 • Published 4 years ago

bot-framework-mutant-whats-adapter

Licence
ISC
Version
0.1.3
Deps
5
Size
10 kB
Vulns
23
Weekly
0

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)
    }
})

Keywords