For developers
Bots in Squeek
A bot is an account that a program answers for. It shows up in search, you can message it, and you can add it to a group or a channel. Here is how to create one from your phone and get it running in a few minutes.
Create a bot in the app
- Open “Profile” → “My bots”.
- Tap “Create bot”. Enter a name — this is how the bot appears in chats, for example
Weather— and a username: Latin letters only, and it must end withbot, for exampleweather_bot. - Tap “Create”. A dialog shows the token — a long string like
7:a91f…:3c0d…. Tap “Share” and send it to yourself (Saved messages, email, anywhere) or long-press to copy it.
The bot now exists: it appears in search as @weather_bot with a “bot” badge, you can message it, and you can add it to a group or a channel.
Run the bot on Node.js
The program that answers for the bot runs on your computer or server. You need Node.js and the squeek-bot library.
mkdir my-bot && cd my-bot && npm init -y && npm install squeek-botCreate bot.js:
const { SqueekBot } = require('squeek-bot');
const bot = new SqueekBot('7:a91f…:3c0d…'); // the token from the app
bot.on('message', async (msg) => {
console.log(msg.from.name, ':', msg.text);
if (msg.text === '/hi') await msg.reply('Hi! 🐀');
});
bot.on('connected', () => console.log('bot is online'));
bot.start();node bot.jsNow send /hi to the bot from the app — it replies.
message— an incoming message.msg.from.nameis the sender,msg.textis the text, andmsg.reply(text)answers in the same chat.connected— the bot has connected to the server.bot.start()— opens the connection and starts receiving messages.
Post to a channel without the library
If the bot only posts to a channel, you do not need the library at all. Make the bot a channel admin and send two HTTP requests from any language.
The token has three colon-separated parts: botId:…:secret. Signing in takes the first (botId) and the third (secret).
curl https://api.squeek.net/auth/bot \
-H 'content-type: application/json' \
-d '{"botId":7,"secret":"3c0d…"}'The response contains accessToken. Then post to the channel, where chatId is the channel’s id:
curl https://api.squeek.net/messages \
-H "authorization: Bearer <accessToken>" \
-H 'content-type: application/json' \
-d '{"chatId":17,"content":"Hello, channel"}'