Created
April 11, 2020 17:21
-
-
Save yarkm13/4d9359f2c96149a012f563ea41849c02 to your computer and use it in GitHub Desktop.
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\Botman\Conversation; | |
use BotMan\BotMan\Messages\Conversations\Conversation; | |
use BotMan\BotMan\Messages\Attachments\Contact; | |
use BotMan\Drivers\Telegram\Extensions\Keyboard; | |
use BotMan\Drivers\Telegram\Extensions\KeyboardButton; | |
class RequestContactConversation extends Conversation | |
{ | |
protected $phone; | |
public function askPhone() | |
{ | |
$this->askForContact( | |
'Press button to send your phone number 👇', | |
function (Contact $contact) { | |
$this->say(__('Your phone '.$contact->phone)); | |
}, | |
null, | |
Keyboard::create() | |
->type(Keyboard::TYPE_KEYBOARD) | |
->oneTimeKeyboard() | |
->resizeKeyboard() | |
->addRow(KeyboardButton::create('Send phone')->requestContact()) | |
->toArray() | |
); | |
} | |
public function run() | |
{ | |
// This will be called immediately | |
$this->askPhone(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for sharing this! I have been trying to figure out how to create a keyboard for so long.