bottenderjs/messaging-apis

Error 400 Bad Request: chat not found

AlexanderProd opened this issue · 3 comments

Whenever I try to send a message to my telegram account I get the following error.

client.sendMessage('xxxxxx', 'Hello World').then(() => {
        console.log('sent');
}).catch(err => console.log(err));
Error: Telegram API - 400 Bad Request: chat not found
    at /Users/alexanderhoerl/Developer/reddit-script/node_modules/messaging-api-telegram/lib/TelegramClient.js:116:17
    at Generator.throw (<anonymous>)
    at step (/Users/alexanderhoerl/Developer/reddit-script/node_modules/messaging-api-telegram/lib/TelegramClient.js:8:362)

    at /Users/alexanderhoerl/Developer/reddit-script/node_modules/messaging-api-telegram/lib/TelegramClient.js:8:561
    at process._tickCallback (internal/process/next_tick.js:68:7)

Error Message -
  Telegram API - 400 Bad Request: chat not found

Request -
  POST https://api.telegram.org/bot701723441:AAGuTVaWZGG-fRJjfUWktZnI6M0BIJu21Ig/sendMessage

Request Data -
  {
    "chat_id": "xxxxxxx",
    "text": "Hello World"
  }

Response -
  400 Bad Request

Response Data -
  {
    "ok": false,
    "error_code": 400,
    "description": "Bad Request: chat not found"
  }

Do I need to start a conversation with my bot before he can send me notifications?

You need to message you bot first before he can send you a message

I was using prefix @ before the chat_id as suggested everywhere. I removed it and it started working.
Note: if your chat id is 12345678 then you need to prefix it with -100 such that it is -10012345678.
Example Postman call:
/sendMessage?chat_id=-10012345678&text=Let's get together

I am facing the similar issue previously its working but now its not working