Created
July 25, 2019 14:32
-
-
Save molbal/3078c5cb881d420e51b72f2f60611b42 to your computer and use it in GitHub Desktop.
Trait example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Conversations; | |
use BotMan\BotMan\Messages\Conversations\Conversation; | |
use BotMan\BotMan\Messages\Incoming\Answer; | |
use BotMan\BotMan\Messages\Outgoing\Question; | |
use SundayIT\ChatbotAdmin\Botman\Middleware\PropertyLoggingTrait; | |
class TestConversation extends Conversation | |
{ | |
use PropertyLoggingTrait; | |
/** @var string */ | |
private $name; | |
/** | |
* @return mixed | |
*/ | |
public function run() | |
{ | |
$this->greet(); | |
} | |
private function greet(): TestConversation | |
{ | |
$question = Question::create("What is your name?") | |
->callbackId('ask_name'); | |
return $this->ask($question, function (Answer $response) { | |
$this->name = $response->getText(); | |
$this->logProperty("name", $this->name, $this->bot->getUser()->getId()); | |
$this->say('Nice to meet you, ' . $response->getText()); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment