%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/ugotscom/bos_naturals/app/Botman/
Upload File :
Create Path :
Current File : /home/ugotscom/bos_naturals/app/Botman/OnboardingConversation.php

<?php

namespace App\Botman;

use BotMan\BotMan\Messages\Conversations\Conversation;
use BotMan\BotMan\Messages\Incoming\Answer;
use BotMan\BotMan\Messages\Outgoing\Question;
use BotMan\BotMan\Messages\Outgoing\Actions\Button;

class OnboardingConversation extends Conversation
{
    protected $name;

    protected $email;

    protected $query;

    public function askName()
    {
        $this->ask('Hi! What is your name?', function(Answer $answer) {
            // Save result
            $this->name = $answer->getText();

            $this->say('Nice to meet you '.$this->name);
            $this->askPhone();
        });
    }

    public function askPhone()
    {
        $this->ask('One more thing - what is your Phone No?', function(Answer $answer) {
            // Save result
            $this->email = $answer->getText();

            $this->say('Great - that is all we need, '.$this->name);
            $this->askService();
        });
    }

    public function askHelp()
    {
        $this->ask('How can I help you?', function(Answer $answer) {
            // Save result
            $this->query = $answer->getText();

            $this->say('Your query has been forwarded, we will contact you soon.');
            $this->askMood();
        });
    }

    public function askMood()
    {
        $this->ask('How are you?', function (Answer $response) {
            $this->say('Cool - you said ' . $response->getText());
            $this->askForDatabase();
        });
    }

    public function askService()
{
    $question = Question::create('Please select the service you are looking for?')
        ->fallback('Unable to create a new database')
        ->callbackId('create_database')
        ->addButtons([
            Button::create('Property Service')->value('PS'),
            Button::create('Property Maintenance')->value('PM'),
        ]);

    $this->ask($question, function (Answer $answer) {
        // Detect if button was clicked:
        if ($answer->isInteractiveMessageReply()) {
            $selectedValue = $answer->getValue(); // will be either 'yes' or 'no'
            $selectedText = $answer->getText(); // will be either 'Of course' or 'Hell no!'
        }
        if($selectedValue=='PS'){
            $this->askPropertyService();

        }
         else{
            $this->say('sorry no');
        }
   });
}


public function askPropertyService()
{
    $question = Question::create('what are you looking for ?')
        ->fallback('Unable to create a new database')
        ->callbackId('create_database')
        ->addButtons([
            Button::create('Rent a Property')->value('rent'),
            Button::create('Sell your property')->value('sell'),
            Button::create('Buy a property')->value('buy'),
            Button::create('Property Management')->value('Pm'),
        ]);

    $this->ask($question, function (Answer $answer) {
        // Detect if button was clicked:
        if ($answer->isInteractiveMessageReply()) {
            $selectedValue = $answer->getValue(); // will be either 'yes' or 'no'
            $selectedText = $answer->getText(); // will be either 'Of course' or 'Hell no!'
        }
        if($selectedValue == 'rent'){
            $this->askPropertyType();

        }
         else{
            $this->say('sorry no');
        }
   });
}
public function askPropertyType(){

    $question = Question::create('What Type of property you would like ?')
        ->fallback('Unable to create a new database')
        ->callbackId('create_database')
        ->addButtons([
            Button::create('Apartment')->value('1'),
            Button::create('House')->value('2'),
            Button::create('Villa')->value('3'),
            Button::create('Retail Space')->value('4'),
        ]);

    $this->ask($question, function (Answer $answer) {
        // Detect if button was clicked:
        if ($answer->isInteractiveMessageReply()) {
            $selectedValue = $answer->getValue(); // will be either 'yes' or 'no'
            $selectedText = $answer->getText(); // will be either 'Of course' or 'Hell no!'
        }
        if($selectedValue == 1){
            $this->say('awesome'. $selectedText);
              $this->askBudget();
        }
         else{
            $this->say('sorry no');
        }
   });
}

public function askBudget(){

    $this->ask('What is your budget?', function(Answer $answer) {
        // Save result
        $this->buget = $answer->getText();

        $this->say('ok '.$this->budget);
       
    });


}
    public function run()
    {
        // This will be called immediately
        $this->askName();
    }
}

Zerion Mini Shell 1.0