-
Notifications
You must be signed in to change notification settings - Fork 63
Creating a Custom Keyboard
Andrey Fidrya edited this page Jun 20, 2016
·
10 revisions
A custom keyboard can be activated like this:
router["/start"] = { (context: Context) -> () in
context.respondAsync("Hello there, \(context.message.from.first_name)! Nice to meet you!")
}
Add this code to the router function:
let markup = ReplyKeyboardMarkup()
context.respondAsync("Here is a keyboard", parameters: ["reply_markup": markup])
let button1 = KeyboardButton()
button1.text = "Any Text"
let button2 = KeyboardButton()
button2.text = "AnyText"
markup.keyboardButtons = [ [ button1, button2 ] ]
context.respondAsync("It's pretty cool", parameters: ["reply_markup": markup])
let markup = ReplyKeyboardMarkup()
context.respondAsync("Here is a keyboard", parameters: ["reply_markup": markup])
This code is necessary and gives the user a custom keyboard
let button1 = KeyboardButton()
button1.text = "Any Text"
let button2 = KeyboardButton()
button2.text = "AnyText"
These lines of code can be played around with. Make your own text and add endless amount of buttons!
markup.keyboardButtons = [ [ button1, button2 ] ]
This can also be messed around with! This is the arrangement of your buttons! Currently it has 2 buttons side by side horizontally. Play around!
Now, play around and create awesome keyboards!