<?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 Sergiy Alonso on Medium]]></title>
        <description><![CDATA[Stories by Sergiy Alonso on Medium]]></description>
        <link>https://medium.com/@sergiy.alonso?source=rss-4d964fbeec6e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*jA17KBcOfEFVjSG7Z6s1yg.jpeg</url>
            <title>Stories by Sergiy Alonso on Medium</title>
            <link>https://medium.com/@sergiy.alonso?source=rss-4d964fbeec6e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 12:53:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sergiy.alonso/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[Google Assistant & Alexa chatbot on Firebase Cloud Functions]]></title>
            <link>https://medium.com/the-cocktail-engineering/google-assistant-alexa-chatbot-on-firebase-cloud-functions-2d7491b0f06d?source=rss-4d964fbeec6e------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d7491b0f06d</guid>
            <category><![CDATA[alexa-skills]]></category>
            <category><![CDATA[alexa]]></category>
            <category><![CDATA[google-assistant]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[firebase-cloud-functions]]></category>
            <dc:creator><![CDATA[Sergiy Alonso]]></dc:creator>
            <pubDate>Fri, 07 Dec 2018 12:18:48 GMT</pubDate>
            <atom:updated>2018-12-18T07:29:48.417Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*q8bDslKjv8-KffuwCP44ww.jpeg" /></figure><p>In this post, I will explain how to make a middleware capable of responding in Google Assistant and Alexa to the same questions. In this case, we will do it with <a href="https://firebase.google.com/docs/functions/?gclid=Cj0KCQiA3IPgBRCAARIsABb-iGJGTBDZzrdmjtIzVgr79NiQksfJwON1rYkF-7-J-_kPQ7RoMxnY9FQaAtiGEALw_wcB"><strong>Firebase Functions</strong></a><strong>. </strong>We will avoid duplicated code putting all the logic in one place.</p><h3>Requirements</h3><p>It’s important to know a little bit of <a href="https://dialogflow.com/"><strong>Dialogflow</strong></a>, <a href="https://developer.amazon.com/es/alexa-skills-kit/"><strong>Alexa Skills</strong></a> and <strong>Nodejs</strong>. It doesn’t have to be advanced, as I will explain every step of the way.</p><h3>Let’s start</h3><h4>First, create your Google project with Firebase.</h4><p>We will go to the <a href="https://console.firebase.google.com/">Firebase</a> console and we will create a new project</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Llf2K43AlkszA3Gb0NmMfw.gif" /></figure><p>We create a directory on our pc/mac where we will develop the middleware. It will consist of 2 functions that will be the <em>fulfillment</em> for <strong>Dialogflow</strong> and <strong>Alexa Skills</strong>. On the terminal, we’ll go to this directory and we’ll write:</p><pre>npm install firebase-functions@latest firebase-admin@latest --save</pre><pre>npm install -g firebase-tools</pre><pre>firebase login</pre><pre>firebase init functions</pre><p>Choose the project ID that you just created, JavaScript, not debuggable (optional) and install dependencies with <strong><em>npm</em></strong>(If you do not have it installed, you can do it <a href="https://www.npmjs.com/get-npm">here</a>)</p><p>We already have our base project, now we are going to install the library of <strong>Google Assistant</strong> and <strong>Dialogflow</strong> and you will see that inside the folder <strong><em>functions</em></strong> you will have a file called <strong><em>package.json</em></strong>, replace it with the following one:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d19b4d0c0bc36d4ff6aa0154bf823a99/href">https://medium.com/media/d19b4d0c0bc36d4ff6aa0154bf823a99/href</a></iframe><p>On your terminal, in <strong><em>[yourProject] / functions</em></strong> directory execute:</p><pre>npm install</pre><h4>Second, create the responses generator</h4><p>The example of this tutorial will be a bot that answers the question: <em>What time is it?.</em> So the logic that gets our response for this <em>intent</em> will be the same to both platforms, then all we have to do is format this response for each channel and return it, as you can see below</p><p>Replace your <strong><em>index.js </em></strong>by this</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8c2e31dca0a01cab3091e0b378c61f27/href">https://medium.com/media/8c2e31dca0a01cab3091e0b378c61f27/href</a></iframe><p>On your terminal, in <strong><em>[yourProject] / functions</em></strong> directory execute:</p><pre>firebase deploy</pre><p>Now in your firebase console in the <strong>Functions</strong> section, you can see the two functions that have been generated and the <strong>URLs</strong> we’ll use for the <em>fulfillment</em> of <strong>Dialogflow</strong> and <strong>Alexa Skills</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2K8mdWDHK2REW0m8jgrKCQ.png" /></figure><h4>Third, connect your answer generator as a fulfillment to Dialogflow and Alexa Skills</h4><p>As you may have seen before in the <strong><em>index.js</em></strong>, the name of the <em>intent</em> that answers what we want is called <strong><em>‘GetCurrentTimeIntet’.</em></strong> In order to do it you have to create this <em>intent</em> with the same name, as seen in the following captures.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GM1vAvaPGScCnNcAtvl-cw.png" /></figure><p>In <strong>Dialogflow</strong>, in the <em>intent</em>(GetCurrentTimeIntent), activate the option that says <em>“Enable webhook call for this intent”</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BdY1iSlHXuFIyeLYC5wFog.png" /></figure><p>In the fulfillment section, enable <strong><em>Webhook</em></strong>, and put in the <strong><em>URL</em></strong><em> </em>the endpoint that we generated before for <strong>Dialogflow</strong></p><p>In <strong>Alexa Skill</strong>s add an <em>intent</em> with the same name as the <em>intent</em> of <strong>Dialogflow</strong>, if you don’t have it you could replace you JSON by the following in the <strong><em>JSON Editor</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X1amab4MXde10aQnGq_mDw.png" /></figure><pre>{<br>    &quot;interactionModel&quot;: {<br>        &quot;languageModel&quot;: {<br>            &quot;invocationName&quot;: &quot;timebot&quot;,<br>            &quot;intents&quot;: [<br>                {<br>                    &quot;name&quot;: &quot;AMAZON.FallbackIntent&quot;,<br>                    &quot;samples&quot;: []<br>                },<br>                {<br>                    &quot;name&quot;: &quot;AMAZON.CancelIntent&quot;,<br>                    &quot;samples&quot;: []<br>                },<br>                {<br>                    &quot;name&quot;: &quot;AMAZON.HelpIntent&quot;,<br>                    &quot;samples&quot;: []<br>                },<br>                {<br>                    &quot;name&quot;: &quot;AMAZON.StopIntent&quot;,<br>                    &quot;samples&quot;: []<br>                },<br>                {<br>                    &quot;name&quot;: &quot;AMAZON.NavigateHomeIntent&quot;,<br>                    &quot;samples&quot;: []<br>                },<br>                {<br>                    &quot;name&quot;: &quot;GetCurrentTimeIntent&quot;,<br>                    &quot;slots&quot;: [],<br>                    &quot;samples&quot;: [<br>                        &quot;What time is it&quot;<br>                    ]<br>                }<br>            ],<br>            &quot;types&quot;: []<br>        }<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nonOr21C0ueMx_DyHnDySw.png" /></figure><p>In the <strong>Alexa Skill</strong>, select the <strong><em>HTTPS</em></strong> endpoint type, paste the <strong><em>alexa url</em></strong><em> </em>from<em> </em><strong>Firebase</strong> and choose the second option <em>“My development endpoint is a sub-domain of a domain that has a wildcard certificate from a certificate authority&quot;</em></p><p><strong>Don’t forget to save the changes on both platforms before submitting</strong></p><h3>Result</h3><p>In <strong><em>Alexa</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fpD4ccIgpLqZBRKJz6Xk0A.png" /></figure><p>In <strong><em>Google Assistant</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e48PugxlI0wtO27-QBhlKg.png" /></figure><blockquote>Any questions you can write me in comments, in Spanish too</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d7491b0f06d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-cocktail-engineering/google-assistant-alexa-chatbot-on-firebase-cloud-functions-2d7491b0f06d">Google Assistant &amp; Alexa chatbot on Firebase Cloud Functions</a> was originally published in <a href="https://medium.com/the-cocktail-engineering">The Cocktail Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Adaptador genérico para RecycleView en Kotlin]]></title>
            <link>https://medium.com/the-cocktail-engineering/adaptador-gen%C3%A9rico-para-recycleview-en-kotlin-454593d4a212?source=rss-4d964fbeec6e------2</link>
            <guid isPermaLink="false">https://medium.com/p/454593d4a212</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[adapter]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[recyclerview]]></category>
            <category><![CDATA[tutorial]]></category>
            <dc:creator><![CDATA[Sergiy Alonso]]></dc:creator>
            <pubDate>Thu, 28 Dec 2017 11:47:39 GMT</pubDate>
            <atom:updated>2018-01-16T12:27:21.050Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0S2V9Vt6xRBpPkV4Y3zj9g.jpeg" /></figure><p>¿Quién no ha tenido que hacer una aplicación Android con una o varias listas? Listas con un adaptador personalizado aunque este hiciese lo mismo en todos los casos (recibir una listas de objetos, pintarla en cada celda y como mucho añadir un clickListener()para devolver el objeto al ser pulsado)</p><p>En este post vamos a ver como se hace un adaptador genérico, que estará contenido en un <strong>SDK</strong> y que podremos utilizar de manera sencilla en todos los proyectos que hagamos a partir de ahora solo con importarlo y un par de cosillas mas que veremos mas adelante.</p><h3>Creación del SDK</h3><p>En nuestro proyecto creamos un nuevo módulo Android Library que llamaremos <strong>commons</strong> y que contendrá todas las clases y extensiones comunes que podremos utilizar en nuestros futuros proyectos.</p><p>En el Gradle de nuestro módulo <strong>commons</strong> y de la <strong>app</strong> vamos a añadir el siguiente plugin <strong>kotlin-kapt</strong> y la dependencia <a href="https://developer.android.com/topic/libraries/data-binding/index.html?hl=es-419"><strong>Databinding</strong></a>, librería que nos permitirá definir nuestro modelo en cada item_layout.xml.</p><pre>...<br>apply plugin: &#39;kotlin-kapt&#39;<br>android {</pre><pre>...</pre><pre>}</pre><pre>dependencies {</pre><pre>...</pre><pre>kapt &#39;com.android.databinding:compiler:3.0.1&#39;</pre><pre>}</pre><h4>Clase BaseFragment()</h4><p>Crearemos esta clase en la carpeta <strong>java </strong>de<strong> commons</strong>, es un sencillo inflater de <strong>fragments</strong>, que se podrá utilizar simplemente implementándola en tu <strong>fragment</strong> y pasándole por el método getLayoutResId(id_de_nuestro_fragment_layout)</p><p>También creamos Extensions.kt es un archivo <strong>Kotlin</strong> que tendrá los métodos que extenderán de las distintas clases para evitar repetir futuro código, como por ejemplo <em>.inflate(), .toast()</em>…</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/31769a239fbe6a769001d22b496776c9/href">https://medium.com/media/31769a239fbe6a769001d22b496776c9/href</a></iframe><h4>Adapter genérico</h4><p>Constará de 2 clases; DataBindingRecycleAdapter ,DataBindingViewHolder y un archivo<strong> .kt</strong> (opcional) para poder añadir imágenes usando la librería de <a href="https://github.com/bumptech/glide"><strong>Glide</strong></a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/920f158666082164e67d07e75d51e8e4/href">https://medium.com/media/920f158666082164e67d07e75d51e8e4/href</a></iframe><h4>Layout genérico</h4><p>En la carpeta <strong><em>res →layout</em></strong> de nuestro <strong>SDK commons<em> </em></strong>creamos fragment_list.xml</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/df2eb412f3865019863fffd3acbb3d3c/href">https://medium.com/media/df2eb412f3865019863fffd3acbb3d3c/href</a></iframe><h4>Clase BindListFragment()</h4><p>Para finalizar crearemos la última clase que tendrá el método necesario para ser implementado en nuestro <strong>fragment</strong><em> </em>y que nos permitirá crear la lista, sólo pasándole el <strong>modelo</strong> y el <strong>item_layout</strong><em> </em>como veremos posteriormente.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dc01f19076dc0f146cc2b2829627ec2f/href">https://medium.com/media/dc01f19076dc0f146cc2b2829627ec2f/href</a></iframe><h3>Cómo utilizarlo</h3><p>Bien, ya tenemos creado nuestro <strong>SDK commons</strong>, ahora vamos a importarlo en nuestra aplicación.</p><pre>...<br>android {</pre><pre>...</pre><pre>}</pre><pre>dependencies {</pre><pre>...</pre><pre>implementation project(path: &#39;:commons&#39;)</pre><pre>}</pre><p>Ahora podemos utilizar las clases que hemos creado en el <strong>SDK commons<em> </em></strong>para nuestra aplicación, en nuestro <strong>fragment</strong> vamos a poner que extienda de BindListFragment()<strong><em> </em></strong>en vez de Fragment()e implementamos los métodos getAdapter() y onViewCreated() como vemos en el ejemplo</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7d77c51755d3ed7db9271a2a7e746508/href">https://medium.com/media/7d77c51755d3ed7db9271a2a7e746508/href</a></iframe><p>Por último, nuestro item_layoutnecesitará saber qué <strong>Modelo</strong> va a recibir y qué va a pintar en cada vista, de esta sencilla manera ya tendríamos todo:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/40caab4455425bdf55efa682441d27b5/href">https://medium.com/media/40caab4455425bdf55efa682441d27b5/href</a></iframe><h3><strong>Conclusión</strong></h3><p>Hemos visto como crear un SDK para futuros proyectos, que nos permita crear <strong>fragments</strong> con listas de manera sencilla</p><p>Evitar repetir código añadiendo funciones que extiendan de otras clases como ViewGroup.inflate() o BaseFragment.toast()</p><p>Utilizar <strong>Databinding</strong> para pintar en el <strong>item_layout</strong> las vistas con el objeto necesario he incluso aplicar funciones en las mismas, como cuando cargamos las imagen usando app:imageUrl=&quot;@{objeto.imageurl} (Función que creamos en BindingAdapters.kt )</p><p>Así mismo, podemos ir alimentando nuestro SDK de clases y métodos que luego nos harán la vida más fácil en futuros proyectos</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=454593d4a212" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-cocktail-engineering/adaptador-gen%C3%A9rico-para-recycleview-en-kotlin-454593d4a212">Adaptador genérico para RecycleView en Kotlin</a> was originally published in <a href="https://medium.com/the-cocktail-engineering">The Cocktail Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>