Build a Telegram picks bot on live Pinnacle odds
This bot watches Pinnacle prices on the PinnFeed WebSocket and posts a message to a Telegram channel whenever a market steams, meaning its price shortens by 5% or more within two minutes in a market with a decent max stake. It is one file, about 70 lines, with no Telegram library: it calls the Bot API directly.
Step 1 — Create the bot#
- In Telegram, open @BotFather, send
/newbotand follow the prompts. Copy the token. - Create a channel, add the bot as an administrator with permission to post.
- Use the channel's public name (
@mychannel) as the chat id, or the numeric id for a private chat.
Step 2 — Set the environment#
export PINNFEED_KEY="pf_live_..." # Builder plan (WebSocket)
export TELEGRAM_TOKEN="123456:ABC..." # from @BotFather
export TELEGRAM_CHAT="@mychannel"
npm install ws
Leave TELEGRAM_TOKEN unset to run in dry-run mode: the bot prints messages instead of sending them.
Step 3 — The bot#
Save as telegram-picks-bot.mjs:
// telegram-picks-bot.mjs: post Pinnacle steam moves to a Telegram channel as "picks".
// npm install ws Node 18+ (global fetch)
// env: PINNFEED_KEY, TELEGRAM_TOKEN (from @BotFather), TELEGRAM_CHAT (e.g. @mychannel or a chat id)
import WebSocket from 'ws';
const WS_URL = process.env.PINNFEED_WS || 'wss://pinnfeed.io/v1/stream';
const { PINNFEED_KEY, TELEGRAM_TOKEN, TELEGRAM_CHAT } = process.env;
const MIN_DROP = Number(process.env.MIN_DROP || 0.05); // 5% shortening...
const WINDOW_MS = Number(process.env.WINDOW_MS || 120000); // ...inside 2 minutes
const SIDES = new Set(['home', 'away', 'draw', 'over', 'under']);
const events = new Map();
const highs = new Map(); // "marketId|outcome" -> [{t, p}]
const sent = new Map(); // "marketId|outcome" -> last alert time
async function post(text) {
if (!TELEGRAM_TOKEN) return console.log('[dry run]', text);
const r = await fetch(`https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendMessage`, {
method: 'POST', headers: { 'content-type': 'application/json' },
body: JSON.stringify({ chat_id: TELEGRAM_CHAT, text, disable_web_page_preview: true }),
});
if (!r.ok) console.error('telegram', r.status, await r.text());
}
function check(m) {
const ev = events.get(m.eventId);
if (!ev || (m.maxStake ?? 0) < 500) return;
const now = Date.now();
for (const o of m.outcomes) {
if (!SIDES.has(o.name)) continue;
const k = `${m.id}|${o.name}`;
const h = (highs.get(k) || []).filter((x) => now - x.t < WINDOW_MS);
h.push({ t: now, p: o.decimal });
highs.set(k, h);
const high = Math.max(...h.map((x) => x.p));
const drop = 1 - o.decimal / high;
if (drop < MIN_DROP || now - (sent.get(k) || 0) < WINDOW_MS) continue;
sent.set(k, now);
const pick = o.name === 'home' ? ev.home : o.name === 'away' ? ev.away : o.name;
const line = o.points == null ? '' : m.type === 'total' ? ` ${o.points}` : ` ${o.points > 0 ? '+' : ''}${o.points}`;
post(`📉 ${ev.sport.toUpperCase()} · ${ev.league?.name ?? ''}\n${ev.home} v ${ev.away}\n` +
`Pick: ${pick} (${m.type}${line})\nPinnacle ${high.toFixed(2)} → ${o.decimal.toFixed(2)} (−${(drop * 100).toFixed(1)}%)\n` +
`Fair now ${o.fair.toFixed(2)} · max stake ${m.maxStake}`);
}
}
function connect(delay = 1000) {
const ws = new WebSocket(WS_URL, { headers: { 'x-api-key': PINNFEED_KEY }, perMessageDeflate: true });
ws.on('open', () => {
delay = 1000;
ws.send(JSON.stringify({ type: 'subscribe', sports: ['soccer', 'tennis', 'basketball'], markets: ['moneyline', 'spread', 'total'], main: true, specials: false }));
});
ws.on('message', (raw) => {
const msg = JSON.parse(raw);
if (msg.type === 'ping') return ws.send('{"type":"pong"}');
if (msg.type === 'snapshot') msg.events.forEach((e) => events.set(e.id, e));
if (msg.type === 'delta') for (const c of msg.changes) {
if (c.kind === 'event') c.op === 'upsert' ? events.set(c.event.id, c.event) : events.delete(c.id);
if (c.kind === 'market' && c.op === 'upsert') check(c.market);
}
});
ws.on('close', () => setTimeout(() => connect(Math.min(delay * 2, 30000)), delay));
ws.on('error', (e) => console.error('ws error:', e.message));
}
connect();
Step 4 — Run and test#
node telegram-picks-bot.mjs
A message looks like this:
📉 SOCCER · Italy - Serie A
Udinese v Fiorentina
Pick: Udinese (spread +0.25)
Pinnacle 1.88 → 1.70 (−9.5%)
Fair now 1.83 · max stake 500
Tune volume with MIN_DROP and WINDOW_MS, for example MIN_DROP=0.08 for fewer, stronger alerts.
Step 5 — Keep it running#
- Run it under
systemd,pm2or a container with restart on failure; the bot reconnects to the WebSocket by itself. - Telegram allows about 20 messages per minute per group or channel. Raise
MIN_DROPif you hit429responses. - Post your record honestly: log each pick and measure it with closing line value.
Questions people ask#
Which PinnFeed plan does the bot need?#
Builder (€99/month) or higher, because it uses the WebSocket. For a slower bot on Free or Hobby, poll /v1/drops every minute instead.
Can I post picks to Discord instead?#
Yes. Replace the post function with a POST to a Discord webhook URL with body {"content": text}.
Is it legal to publish picks?#
Rules on betting tips and advertising vary by country. Check the rules where you and your audience are, and never present picks as guaranteed.