Last active
February 2, 2022 07:14
-
-
Save dotcypress/644511bc52a0f5cc6f899cc6bde63cae to your computer and use it in GitHub Desktop.
How to build Telegram bot with Wit.ai Bot Engine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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
Where can we deploy these bots? Is it more than enough if we just deploy this code once we make our not?