Skip to content

Instantly share code, notes, and snippets.

@Kennyl
Forked from dotcypress/wit-telegram-bot.js
Created January 31, 2017 12:03
Show Gist options
  • Save Kennyl/6deb45827969fbd213c2b62d461a859d to your computer and use it in GitHub Desktop.
Save Kennyl/6deb45827969fbd213c2b62d461a859d to your computer and use it in GitHub Desktop.
How to build Telegram bot with Wit.ai Bot Engine
// npm install telegraf telegraf-wit
var Telegraf = require('telegraf')
var TelegrafWit = require('telegraf-wit')
var app = new Telegraf(process.env.BOT_TOKEN)
var wit = new TelegrafWit(process.env.WIT_TOKEN)
app.use(Telegraf.memorySession())
app.use(wit.middleware())
wit.onMessage(function * () {
yield this.reply(this.state.wit.message)
})
app.startPolling()
// Other example: https://github.com/telegraf/telegraf-wit/blob/develop/examples/wit-bot.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment