<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ivan Marinin on Medium]]></title>
        <description><![CDATA[Stories by Ivan Marinin on Medium]]></description>
        <link>https://medium.com/@fsharpfan?source=rss-fb6a8ee98e69------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*K1LtzMWtTm8vJsPp</url>
            <title>Stories by Ivan Marinin on Medium</title>
            <link>https://medium.com/@fsharpfan?source=rss-fb6a8ee98e69------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 12:32:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@fsharpfan/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Funogram.Keyboard: How to reserve seats on an airplane using F # and telegram]]></title>
            <link>https://medium.com/@fsharpfan/funogram-keyboard-how-to-reserve-seats-on-an-airplane-using-f-and-telegram-6f7035e9c698?source=rss-fb6a8ee98e69------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f7035e9c698</guid>
            <category><![CDATA[telegram]]></category>
            <category><![CDATA[fsharp]]></category>
            <dc:creator><![CDATA[Ivan Marinin]]></dc:creator>
            <pubDate>Sun, 31 Mar 2019 08:01:54 GMT</pubDate>
            <atom:updated>2019-03-31T16:14:17.622Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/940/0*BYlQTXCgCbBzY4n4.png" /><figcaption>Embraer E170</figcaption></figure><p>I like the Telegram. It is an awesome messenger, it has very interesting features and it’s developer-friendly. Telegram Bot is a very good alternative to your own mobile / desktop client app. If you need some simple way to interact with users (ask something or send something) you can concentrate on it and don’t care about your own client app. There are a lot of different libraries to create telegram bot for different platforms and languages ( including my favorite F#:<a href="https://github.com/Dolfik1/Funogram">Funogram</a>)</p><p><a href="https://github.com/Dolfik1/Funogram">Funogram</a> is <a href="https://core.telegram.org/bots/api">Bot API</a> wrapper adapted to F# type system. You can create your own telegram bot using <a href="https://telegram.me/BotFather">BotFather</a> and Funogram in <a href="https://medium.com/@worldbeater/funogram-writing-telegram-bots-in-f-f27a873fa548">about 5 minutes</a>.</p><p>But there’s a problem. As Funogram is just a wrapper over API, you have to dive in it if you want to use the advanced features, like <a href="https://core.telegram.org/bots/2-0-intro#new-inline-keyboards">telegram inline keyboard</a>. I faced this problem when I tried to implement a calendar keyboard in my bot.</p><p>Yes,<a href="https://github.com/dohly/funogram.keyboard/blob/master/calendar.gif"> I did it</a>, but I noticed that everything I implemented can be reused (thanks F# type system). A few days later my friend (also F# fan) asked me: “Hey, I’ve heard you know how to implement inline keyboard for telegram. Could you help me?”</p><p>I answered “Yes, sure”. And today I’m happy to present you <a href="https://github.com/dohly/funogram.keyboard">Funogram.Keyboard</a>. It’s Funogram extension allows you to use one of existing keyboards or define your own keyboard. It has quite simple api and makes interact with inline keyboards very simple.</p><p>Let’s try to reserve a few seats in the flight.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*5JDGLxJwRz6dKagRynJ_dw.jpeg" /></figure><p>First of all, we need to define our <a href="https://fsharpforfunandprofit.com/ddd/">domain entity</a>. Also, let’s add two functions to serialize and deserialize seat.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b29ae3afa0b2e1479c0e768e07f7cdf5/href">https://medium.com/media/b29ae3afa0b2e1479c0e768e07f7cdf5/href</a></iframe><p>Now we can define our keyboard — it’s a virtual device to enter a list of seats. Let’s set basic settings first.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2aa221d91b58ee4bf89b643b6f6ac9cd/href">https://medium.com/media/2aa221d91b58ee4bf89b643b6f6ac9cd/href</a></iframe><p>We didn’t implemented GetKeysByState function. Let’s do it.<br>Funogram.Keyboard supports three types of buttons:</p><ul><li>keys.Ignore: nothing happens when user presses it</li><li>keys.Change: state of keyboard is changed when it’s clicked</li><li>keys.Confirm: selected value is sent to DoWhenConfirmed function</li></ul><p>We need to decide how to display seat map in our keyboard.</p><ul><li>We will use empty buttons to display central aisle that separates the seats A C from the seats D F</li><li>To display the seats already reserved by someone else we’ll use “X” buttons</li><li>Let’s mark selected seats with &gt; {seat} &lt; chars</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d09039484e5c50f1e61660bfc47acd34/href">https://medium.com/media/d09039484e5c50f1e61660bfc47acd34/href</a></iframe><p><em>keys</em> is the special syntax to build keyboards. As you can see in the code, first two rows are business class. Then we’ll draw economy class seats. And then we’ll add two buttons to confirm or cancel.</p><p>Now we need to call it from our bot:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b6aa442e9a3a1b7f5ca01f4c9f586f64/href">https://medium.com/media/b6aa442e9a3a1b7f5ca01f4c9f586f64/href</a></iframe><p>That’s it. Let’s run our bot and check how it works</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/1*qTq_4tBlsgI6hDoNJ92MXQ.gif" /></figure><p>You can check full working example<a href="https://github.com/dohly/funogram.keyboard/tree/master/DemoBot"> here.</a></p><p>Happy F# coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f7035e9c698" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>