0

Hi guys so what i'm trying to do here is when the botman hears something that already in the code it will return if statement, if it hears something other than that it will go get reply from dialogflow. Is it possible or not? I'm new to botman and trying to develop it for school project.

Below is my code: I still don't know how to do it and don't know if it is possible.


    if ($input == 'School info'){
        $bot->reply('Give some info about school');
    }
    
    else{
        //get reply from dialogflow
        $dialogflow = DialogFlow::create('en');
        $botman->middleware->received($dialogflow);
        $botman->hears('(input.*)', function ($bot) {
            $extras = $bot->getMessage()->getExtras();
            $bot->reply($extras['apiReply']);
        })->middleware($dialogflow);
    }

});

1 Answers1

0

so i can do that by creating new intent that detect other's info, then in the Botman i compared the value of the dialogflow responses. if the value is true, then return the information from Botman codes. The code is like below:

$botman = resolve('botman');

 

$dialogflow = DialogFlow::create('en');
$botman->middleware->received($dialogflow);
$botman->hears('(input.*)', function ($bot) {
    $extras = $bot->getMessage()->getExtras();

    if ($extras['apiReply'] == 'IntroductionOfSchool' ){
            $bot->typesAndWaits(1);
            $bot->reply('Hi there, for your information. Tell more about School Info!');
            $bot->typesAndWaits(1);
            $bot->startConversation(new OptionsConversation());  
        
    }
    else{
        //get reply from dialogflow
        $bot->reply($extras['apiReply']);
        }           
})->middleware($dialogflow);

I think this is not a good way to do it, but at least it does the trick. Feel free to share other's method to do this.