title: Telegram Bot Private bot [security]
body: <p>I have a Telegram Bot written in javascript (<a href="https://github.com/yagop/node-telegram-bot-api" rel="nofollow noreferrer">node-telegram-bot-api</a> + <a href="https://sailsjs.com/" rel="nofollow noreferrer">SailsJs</a>). I want to create a bot that answer private information, for example, my /todayTasks or /myAgenda. Can I block people from using my bot in private chats?</p>
  
  <p>I tried to use <a href="https://core.telegram.org/bots/api#leavechat" rel="nofollow noreferrer">leaveChat()</a> when the bot receives <code>/start</code> but it only works in group chat. </p>
  
  <blockquote>
    <p>Unhandled rejection Error: ETELEGRAM: 400 Bad Request: chat member status can't be changed in private chats</p>
  </blockquote>
  
  <p>My Code:</p>
  
  <pre><code>bot.onText(/\/start/, function(msg) {
      const chatId = msg.chat.id;
  
      CheckAuthorized(chatId).then(function(user) {
          if (!user) {
              bot.sendMessage(chatId, 'Sorry, you are not allowed to ask me.');
              bot.leaveChat(chatId); //&lt;---- ERROR HERE!
              return;
          }
  
          bot.sendMessage(chatId, 'Hello my friend.');                
      });
  });
  </code></pre>
  
  <p>Of course, I can use an Authentication Policy to run before every request, if there is no other option.</p>