<?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 Paul Hansa on Medium]]></title>
        <description><![CDATA[Stories by Paul Hansa on Medium]]></description>
        <link>https://medium.com/@biggestcookie?source=rss-77bcf6d77c2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*U4UzvkLGklhwJIMNujLVjQ.jpeg</url>
            <title>Stories by Paul Hansa on Medium</title>
            <link>https://medium.com/@biggestcookie?source=rss-77bcf6d77c2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 14 Nov 2026 09:40:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@biggestcookie/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[Eatware — Creation of a flexible, modular bot with Dialogflow and FastAPI]]></title>
            <link>https://itnext.io/eatware-creation-of-a-flexible-modular-bot-with-dialogflow-and-fastapi-a11b19fa8b25?source=rss-77bcf6d77c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/a11b19fa8b25</guid>
            <category><![CDATA[slack]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[slackbot]]></category>
            <dc:creator><![CDATA[Paul Hansa]]></dc:creator>
            <pubDate>Fri, 16 Oct 2020 14:02:56 GMT</pubDate>
            <atom:updated>2022-05-27T02:28:15.429Z</atom:updated>
            <content:encoded><![CDATA[<h3>Eatware — Creation of a flexible, modular bot with Dialogflow and FastAPI</h3><h4>How we built a Slackbot in two days to plan our team lunches for us.</h4><p>Written by <a href="https://twitter.com/jincontroller">Jin Jeong</a>, <a href="https://github.com/TsyooHUB">Thomas Yoo</a>, and <a href="https://github.com/biggestcookie">Paul Hansa</a>.</p><h3>Background</h3><p>Back when we were actually in the office, our team efficiency was plagued with a recurring problem — we never knew where we wanted to eat. Team lunches became a difficult task to plan around, but as developers, we held both the great power and responsibility to automate trivial problems with new and popular technologies.</p><p>With our latest internal hackathon at NCR, we were given the opportunity to hack with Slack and create Slack apps with the help and advice from the Slack team. Our hackathon team came together to create a solution to this problem once and for all in our Slack workspace. With the use of <a href="https://cloud.google.com/dialogflow">Dialogflow</a>, a platform that offers an interface for integrating natural language into apps, and <a href="https://fastapi.tiangolo.com/">FastAPI</a>, a simple yet performant API framework for Python, we were easily able to create an interactive chatbot, named Eatware, that would do our bidding.</p><figure><img alt="GIF demonstration of Eatware, our Slack bot" src="https://cdn-images-1.medium.com/max/475/1*veoKhx8pq9dKfXFOf9ly_A.gif" /><figcaption>If you don’t know where to eat, try Eatware!</figcaption></figure><p>Here’s how we quickly set up our application using these three technologies.</p><h3>Application Structure</h3><p>We can split up our application structure into three layers:</p><ul><li><strong>Our presentation layer, Slack,</strong> allows the user to interact with the bot and receives information from it.</li><li><strong>Our language processing layer, Dialogflow,</strong> directly receives message info from Slack and parses it.</li><li><strong>Our backend layer, the Eatware API,</strong> receives webhook requests from Dialogflow, pulls restaurant information from external APIs, and sends the results back to Slack.</li></ul><figure><img alt="Diagram of application structure" src="https://cdn-images-1.medium.com/max/1024/1*YsMElnkdvwOSQdpZN2ZGwA.jpeg" /></figure><p>Beginning with the presentation layer, we have the user prompt the bot to begin the experience. We identified the need for the user to converse with the bot in natural language to be a core part of the experience, so it blends in naturally with a team channel’s conversation (and it’s also a fun excuse to use the technology).</p><p>The user tags the bot and asks it in natural language that they’re looking for some food.</p><figure><img alt="@Eatware, I’m looking for a bite to eat." src="https://cdn-images-1.medium.com/max/589/0*M0uxdXZo3hkEvOK4" /></figure><p>Dialogflow, the language-processing layer, is configured with Slack to read all the requests that mention the registered @Eatware application. It reads the sentence and uses the information we’ve trained it with to identify the user’s intent and any parameters they may have supplied. Dialogflow will respond in a conversation flow, prompting the user for any missing parameters, and when it’s reached a satisfactory point, it will make a webhook call to a location of our choosing. In our case, it’s an API we’ve set up to receive this call.</p><p>Our backend layer, built with FastAPI, receives the now-complete payload of parameters from the user and makes a call to an external service with our restaurant search terms. After this call is performed, our API maps the external response to a Slack payload and sends the response to Slack in order to respond as the bot.</p><p>Now that we’ve covered how the application is set up, let’s get into the finer details of each part.</p><h3>Dialogflow</h3><p>Dialogflow is an end-to-end development tool used to create conversational interfaces for websites and applications. It can also be used to interface with multiple platforms including Facebook, LINE, Telegram, and more. For our particular project we integrated with Slack, which allowed us to test features with our fellow coworkers directly.</p><p>Dialogflow on Eatware is our application’s middle layer, taking in user inputs flexibly from Slack, parsing relevant information out from a statement, then sending it as a webhook request to our API. When the API returns a response, Dialogflow takes the information, pieces it together into a user-friendly format, then outputs it back to the user as a Slack message.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*94evYjdS7pKdOc9NRoBvEg.png" /></figure><p>The main factor here is training our Dialogflow agent to recognize common sentence patterns that the user might say and determine keywords that fall into a category.</p><p>When presented with the sentence:</p><blockquote>“Help me find an affordable Chinese restaurant nearby”</blockquote><p>Dialogflow initially will not recognize keywords as meaningful data. However, by manually training it by setting up a few words in its dictionary, such as “affordable = price” , “Chinese = food preference”, and “nearby = address”, the sentence becomes parse-able parameters for our agent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*T8p6CYDi1u4vlRW8zDXPEg.png" /></figure><p>And thanks to its detection functionality, we don’t have to individually bind every word to a category; Dialogflow will attempt to do so itself when it finds a similar sentence structure. So next time when we ask the bot to “help me find an expensive Italian restaurant in Atlanta”, the agent detects the similarities in the sentence, deduces the user’s intent, and already correctly assumes the respective categories. As with all machine learning, Dialogflow improves its NLP prowess through everyday usage and user feedback.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*ZUgBetaGp4z4X8nt5NQv6A.png" /></figure><p>Once the parameters are identified, we can allow Dialogflow to passes these to a <a href="https://cloud.google.com/dialogflow/es/docs/fulfillment-overview">fulfillment webhook request</a> to our backend layer.</p><h3>The Backend</h3><p>For our backend, we were excited to choose FastAPI, a modern web API framework for Python. It takes advantage of Python’s recent type hint features, and provides easy model creation with <a href="https://fastapi.tiangolo.com/python-types/#pydantic-models">Pydantic</a>, which provides helpful IDE type error reporting as well as automatic request/response validation.</p><p>We first set up a POST route to receive Dialogflow’s webhook request. When Dialogflow passes parameters into Eatware’s API, we return an initial response to Dialogflow, which forwards this response to Slack, in order for both Dialogflow and the user to know that their request was successfully received. In the meantime, FastAPI’s <a href="https://fastapi.tiangolo.com/tutorial/background-tasks/">background tasks</a> handle our external call to fetch restaurant information.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/04990ac370789d4b0de1a246cde26546/href">https://medium.com/media/04990ac370789d4b0de1a246cde26546/href</a></iframe><p>In our case we’ve chosen Yelp as our external service, as it was free to use, easy to get started with, and is a well-established platform.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0d66708948176382c0b7ee06395330c5/href">https://medium.com/media/0d66708948176382c0b7ee06395330c5/href</a></iframe><p>Upon receiving Yelp’s response, we format it nicely into Slack’s <a href="https://api.slack.com/block-kit">Block Kit</a>, which is a collection of components used to create custom visuals and interactivity in messages. For us, this meant parsing our Yelp response, grabbing rating, distance, and restaurant information, and throwing them together into the block format to create an appealing visualization and summary of the restaurant’s basic details and contact information.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8a02d27fe24569608834511953b08f72/href">https://medium.com/media/8a02d27fe24569608834511953b08f72/href</a></iframe><p>Finally, the created block is sent to our Slack bot, where it displays the block as a message.</p><figure><img alt="Image of restaurant results" src="https://cdn-images-1.medium.com/max/669/1*wmCu8FzmmJstMYn62T54cw.png" /></figure><h3>Conclusion</h3><p>We had a wonderful time developing with Slack, Dialogflow, and FastAPI and found it fairly effortless to hook them together. The NCR Hackathon provided our team a great opportunity to explore new technologies that we’ll definitely be revisiting in the future.</p><p>Thanks to the flexibility provided by GCP’s Dialogflow and the modularity of our API, we can easily add support for many other platforms. By implementing our external calls as a service, we can swap out usage of Yelp for another service, such as NCR’s own internal restaurant API, or choose to interface through another chat app aside from Slack.</p><p>If you’d like to check out the API for yourself, our source code is provided below!</p><p><a href="https://github.com/biggestcookie/Eatware">biggestcookie/Eatware</a></p><h4>About the Authors</h4><p>Paul, Jin, and Thomas are recent graduates and software engineers at NCR. Along with developing applications with NCR’s Hospitality &amp; Convenience and Fuel Retail solutions, they enjoy playing fighting games and creating fun new web apps.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a11b19fa8b25" width="1" height="1" alt=""><hr><p><a href="https://itnext.io/eatware-creation-of-a-flexible-modular-bot-with-dialogflow-and-fastapi-a11b19fa8b25">Eatware — Creation of a flexible, modular bot with Dialogflow and FastAPI</a> was originally published in <a href="https://itnext.io/">ITNEXT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>