Answer the question
In order to leave comments, you need to log in
How to make the bot respond only when it is called?
How to make a telegram bot answer only when it is accessed by a keyword, but view all correspondence at the same time?
Answer the question
In order to leave comments, you need to log in
What is meant by viewing all correspondence?
If you need to do by keyword, then you can add either a handler to a command or a condition and to which it should respond.
Handler can be done like this
@dp.message_handler(commands=['reg'])
async def enter_reg(message: types.Message):
await message.answer('Вы начали регистрацию в боте.\n'
'Укажите ваше имя')
@dp.message_handler(content_types='text')
async def new_message(message: types.Message):
print(message.text)
if message.text == 'привет':
await bot.send_message(message.from_user.id, 'введено ключевое слово')
Just write hello to the bot and he will answer you,
but don't forget to enter the token
from aiogram import types, Dispatcher, executor, Bot
TOKEN = " "
bot = Bot(TOKEN)
dp = Dispatcher(bot)
@dp.message_handler(text='hello') # text='hello' Здесь укажи на какой текст должен отвечать бот
async def start(message: types.Message):
await bot.send_message(message.chat.id, 'jojo')
if __name__ == '__main__':
executor.start_polling(dp)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question