S
S
seniannak2021-11-27 20:32:39
Python
seniannak, 2021-11-27 20:32:39

How to get phone number from sent aiogram contact?

When you click on the button with request_contact=True, you need to get the phone number from contact

@dp.message_handler(state=Estate.area)
async def third_question(message: types.Message, state: FSMContext):
    async with state.proxy() as data:
        data['area'] = message.text
    await Estate.next()
    await message.reply("Предоставьте пожалуйста свой номер телефона, менеджер свяжется с вами в ближайшее время", reply_markup=kb.contact_markup) 
    
@dp.message_handler(state=Estate.contact)
async def fourth_question(message: types.Contact, state: FSMContext):
    global plan
    if message.contact != None:
        async with state.proxy() as data:
            data['contact'] = message.contact.phone_number
        await sqlite_db.sql_add_command(state,plan)
        plan = ""
        await state.finish() 
        await message.answer("Ваша заявка принята и вскоре будет рассмотрена ✅", reply_markup=kb.menu_markup)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question