Skip to content

Instantly share code, notes, and snippets.

@yarkm13
Created April 11, 2020 17:21
Show Gist options
  • Save yarkm13/4d9359f2c96149a012f563ea41849c02 to your computer and use it in GitHub Desktop.
Save yarkm13/4d9359f2c96149a012f563ea41849c02 to your computer and use it in GitHub Desktop.
<?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();
}
}
@manavy1998
Copy link

Thank you for sharing this! I have been trying to figure out how to create a keyboard for so long.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment