The bot sends a lot of messages?

Made the bot, checked all the work, responding immediately, but that's the problem, I write him one message, and he begins to answer without stopping what the problem is don't know how to do it. Will attach a screenshot

import vk_api
from vk_api.add import VkLongPoll, VkEventType
import random

token = 
vk = vk_api.VkApi(token=token)
add = VkLongPoll(vk)

def write_message(user_id, message):
 vk.method('messages.send', {'user_id': user_id, 'message' : message, 'random_id': random.randint(0, 100000)})

def main():
 for event in add.listen():
 if event.type == VkEventType.MESSAGE_NEW:
 if event.to_me:
 request = event.text
 if event.to_me:
 request = event.text.lower()
 if request == 'Hello':
 write_message(event.user_id, 'Hey, my friend!')

April 4th 20 at 00:42
1 answer
April 4th 20 at 00:44
As I understand it when you write the bot the first time then check that message for you (bot) assign the value of the request message, and after checking what it contains, so .MESSAGE_NEW, and responds to the message that you send on behalf of the bot in response to the request, but since they are not from you the contents of the request does not change; it always contains "Hello". So that's how it should be:
if event.to_me:
 request = event.text
 if request == 'Hello':

Find more questions by tags Python