phplaraveltelegram-botphp-telegram-bot

how to get response from user in telegram bot php when trying to validate register & crypto payment


im trying to code a telegram bot for shop in telegram bot user can select a product and pay the invoice and get product. we have a section in bot for users who wants to be a reseller. for registering as reseller user must do 4 jobs : 1 - create metamask wallet (validation : public address) 2 - create account in our site (validation : userID in site) 3 - buy product in site (validation : invoiceID) 4 - submit form in our site (validation : userID in site)

we have a button when user clicked we show user a new message with 4 inlineButtons. when clicking on button 1 a new message sent to user with video and description for what user must do under the message we have a button named : validate i want when user click validate robot send new message and say something after that user send validation query and robot validate it.

i have write the code but stock on validator after clicking the validate button , we sent a message and show user what we need for this step (for example wallet address) but i dont know how to see from bot what user sended i think we must do something with previous message or something like callbackquery but i dont know what to do... can any one help me? i use laravel and telegram-bot-sdk.com library


Solution

  • i have used a database for storing user states first after user click start the process button we create a new record for this user(before that we check if the user has been joined to bot and chanel or not also if user completed the register in bot ) after that we process the steps and check user answers for the values we want for example :

    if (preg_match('/^(0x)?[0-9a-fA-F]{40}$/' , $this->Data['message']['text'])){
        $WalletAddress = $this->Data['message']['text'];
        //get user wallet and store data ....
    }
    

    here when user send a wallet address to robot , you will receive the anser and we will add a if/else and check for user state in DB if user has not passed step 1 we will get and check answer for first step and if user passed step 1 we will start step 2 works..... for step 3,4 we can create regex because our site id's have a algorithme and we can check if user passed user id or not. for example :

     if (preg_match('/^id\d.alg$[0-9]]/i' , $this->Data['message']['text'])){
    

    we can replace pattern to site our site pattern and in the end if anyone has the better option and code style I will be happy to listen to your words