I’m trying to load test my Telegram bot using k6 by simulating multiple virtual users (VUs) to send messages to the bot, but the bot is sending messages to me instead of receiving them. I’m using the Telegram Bot API and the correct bot token and chat ID, but when running the test, the bot sends messages back to the chat instead of receiving and processing them. Here’s the scenario: I want to test how my bot handles multiple VUs sending messages to the bot. However, instead of receiving the message, the bot sends messages back to me.
import http from 'k6/http';
import { check, sleep } from 'k6';
const token = 'YOUR_BOT_TOKEN'; // Replace with your bot's token
const chatId = 'YOUR_CHAT_ID'; // Replace with your chat ID
const url = `${token}/sendMessage`;
export let options = {
vus: 10, // Number of virtual users
duration: '30s', // Duration of the test
};
export default function () {
// Define the payload to send to the bot
const payload = JSON.stringify({
chat_id: chatId, // The chat ID you want the bot to send a message to
text: 'Hello, this is a test message!',
});
const params = {
headers: {
'Content-Type': 'application/json',
},
};
// Send the message to the bot
const res = http.post(url, payload, params);
// Check if the response is successful (HTTP 200)
check(res, {
'message sent successfully': (r) => r.status === 200,
});
// Sleep to simulate user think time
sleep(1);
}