telegraf-chatbase

1.0.2 • Public • Published

Chatbase middleware for Telegraf

Chatbase middleware for Telegraf (Telegram bot framework)

Installation

$ npm install telegraf-chatbase

or using yarn:

$ yarn add telegraf-chatbase

Usage

import Telegraf from 'telegraf'
import TelegrafChatbase from 'telegraf-chatbase'
 
const bot = new Telegraf(process.env.BOT_TOKEN)
const chatbase = new TelegrafChatbase({
    token: process.env.CHATBASE_TOKEN, // Your chatbase.com token, required
    platform: 'nodejs', // Bot platform, optional
    version: '1.0' // Bot version, optional
})
 
 
bot.use(chatbase.middleware())
 
 
bot.command('start', ctx => {
    // Track message. All fields are optional.
    ctx.chatbase.track({
        intent: 'start', // The intent of the message
        isFeedback: false, // Is the message a feedback from the user
        isHandled: true, // False if the message was not handled
    })
    ctx.reply('Hello!')
})
 
 
bot.launch()

Package Sidebar

Install

npm i telegraf-chatbase

Weekly Downloads

2

Version

1.0.2

License

MIT

Unpacked Size

7.43 kB

Total Files

6

Last publish

Collaborators

  • chmodd