Upwork Jobs Finder (Telegram notifications)

Maksym Bilan
3 min readJan 5, 2019

Nowadays there are a lot of solutions which uses Telegram bots. So, I decided to try to do something related. There is a convenient Slack bot which can parse RSS feed and pushes the messages to the channel, but I wanted to find the same solution for Telegram.

I would like to share my experience with you, perhaps it will be useful for someone. I used Node.js and I’m not an expert of it, so don’t judge hard. Let’s do it step by step.

First of all, you have to find your RSS feed. Upwork provides it, it really easy to find.

The second thing that we have to do, to create Telegram Bot (from where we will post the message) and Telegram Channel (where we gonna receive the messages).

It’s really easy to create the Telegram Bot, just follow the link:

An important thing, during the conversation with the bot, it provides a token, don’t miss it.

About the channel, it’s simple as well, just go to Telegram app.

And at this step, we have everything we need. Let’s go to write the code.

We need to have 3 main parts of the app:

  1. RSS Reader, we need to parse our feed link.
  2. The database to store received elements to avoid duplication of messages.
  3. Telegram API to send messages.

I’ve chosen node-feedsub to parse RSS, lowdb as database, and telegraf to send messages.

And here is a simple script:

const credentials = require('./credentials.json')const FeedSub = require('feedsub')
const rssFeed = credentials.rss_feed
let reader = new FeedSub(rssFeed, {
interval: 1 // Check feed every 1 minute.
})
const low = require('lowdb')
const FileSync = require('lowdb/adapters/FileSync')
const adapter = new FileSync('db.json')
const db = low(adapter)
db.defaults({ feed: [] }).write()const Telegraf = require('telegraf')
const Extra = require('telegraf/extra')
const session = require('telegraf/session')
const token = credentials.telegram_bot_token
const bot = new Telegraf(token)
// Register session middleware.
bot.use(session())
// Register logger middleware.
bot.use((ctx, next) => {
const start = new Date()
return next().then(() => {
const ms = new Date() - start
console.log('response time %sms', ms)
})
})
reader.on('item', (item) => {
console.log(item.title)
const itemInDb = db.get('feed').find({ link: item.link }).value()
if (itemInDb) {
console.log("This item is already exists:")
console.log(itemInDb.link)
} else {
db.get('feed').push(item).write()
var message = item.description
bot.telegram.sendMessage(credentials.telegram_channel, message, Extra.HTML().markup())
}
})
reader.start()

The result:

The full source code you can find here. Thanks for reading.

--

--

Maksym Bilan

Software Engineer at @MySwimPro |  swift/objc/c++ | 🇺🇦 | family 👨‍👩‍👧 | swimmer 🏊‍♂️ | optimist ⚡️ | superhero for my 👧