60 lines
2.1 KiB
PHP
60 lines
2.1 KiB
PHP
<?php
|
|
|
|
// namespace App\Conversations;
|
|
namespace App\Controllers\Chatbot;
|
|
|
|
use BotMan\BotMan\Messages\Conversations\Conversation;
|
|
use BotMan\BotMan\Messages\Outgoing\Question;
|
|
use BotMan\BotMan\Messages\Outgoing\Actions\Button;
|
|
|
|
use App\Helpers\ChatbotHelper;
|
|
|
|
class NetworkHospitalConversation extends Conversation
|
|
{
|
|
|
|
|
|
public function run()
|
|
{
|
|
$this->showHospitalMenu();
|
|
}
|
|
|
|
protected function showHospitalMenu()
|
|
{
|
|
$question = Question::create("Choose your Network Hospital option:")
|
|
->addButtons([
|
|
Button::create("🔹 Search by City")->value("search_city"),
|
|
Button::create("🔹 Search by Pincode")->value("search_pincode"),
|
|
Button::create("◀️ Go Back")->value("go_back"),
|
|
]);
|
|
|
|
$this->bot->ask($question, function ($answer) {
|
|
switch ($answer->getValue()) {
|
|
case "search_city":
|
|
$this->bot->ask("Enter the City Name",function ($response){
|
|
// $cityName = $response->getText();
|
|
$hospital_link = ChatbotHelper::getHospitalLink();
|
|
$this->say("Searching for hospitals in .....");
|
|
|
|
$this->say('<a href="' . $hospital_link['network_hospitals'] . '" target="_blank">Click here for hospital details</a>');
|
|
$this->bot->startConversation(new doYouWantToContinueConversation());
|
|
});
|
|
break;
|
|
case "search_pincode":
|
|
$this->bot->ask("Enter the Pincode",function ($response){
|
|
$pincode = $response->getText();
|
|
$this->say("Searching for hospitals in ".$pincode.'.....');
|
|
});
|
|
break;
|
|
case "go_back":
|
|
$this->bot->startConversation(new MainMenuConversation());
|
|
break;
|
|
default:
|
|
$this->say("Invalid selection. Please choose an option.");
|
|
$this->showHospitalMenu();
|
|
break;
|
|
}
|
|
});
|
|
}
|
|
|
|
}
|