<?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 Alessia Sacchi on Medium]]></title>
        <description><![CDATA[Stories by Alessia Sacchi on Medium]]></description>
        <link>https://medium.com/@alessiasacchi?source=rss-55e4556cd81b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*-MpIUc_pGfeKJaDJhhnndA.jpeg</url>
            <title>Stories by Alessia Sacchi on Medium</title>
            <link>https://medium.com/@alessiasacchi?source=rss-55e4556cd81b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 03:33:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alessiasacchi/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[Generative AI is new and exciting but conversation design principles are forever]]></title>
            <link>https://medium.com/google-cloud/generative-ai-is-new-and-exciting-but-conversation-design-principles-are-forever-193371489f99?source=rss-55e4556cd81b------2</link>
            <guid isPermaLink="false">https://medium.com/p/193371489f99</guid>
            <category><![CDATA[conversation-design]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[conversations]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[best-practices]]></category>
            <dc:creator><![CDATA[Alessia Sacchi]]></dc:creator>
            <pubDate>Thu, 28 Dec 2023 14:52:08 GMT</pubDate>
            <atom:updated>2025-01-23T14:26:27.774Z</atom:updated>
            <content:encoded><![CDATA[<p>Generative AI filled us with wonder in 2023 but all magic comes with a price. At first glance, it seems like Large Language Models (LLMs) and generative AI can serve as a drop-in replacement for traditional chatbots and virtual agents. In reality, because LLMs are generalist word probability machines trained on a huge corpus of humanity, it is more important than ever that virtual agents powered by generative AI have access to the latest information and specific details about products or services. Furthermore, given that LLMs are non-deterministic by nature, what seems like creativity and open-ended possibilities to a developer might be perceived as inconsistency, quality issues, liability, or risk in business-critical industries such as finance, healthcare, or retail.</p><p>As the end of the year is approaching, let’s wind down and reflect upon the fundamental principles required to preserve the human element when designing conversational flows, chatbots, virtual agents, or customer experiences. The generative AI that we have been using this year in conversation brings so much excitement but there’s a counterpart to everything. Designing loquacious bots that actually help users solve a problem or make transactions takes strong grounding in the science of conversational AI and a healthy dose of hands-on tinkering as we aim to strike a balance between generating creative content and adhering to conversation best practices.</p><p>Let’s review a few design principles and pitfalls to keep in mind when<strong> </strong>blending generative language with deterministic agent design.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*inmzJp-OOo13cyX_Ku3fcA.jpeg" /><figcaption>Rely on unwavering fundamental principles to guide you when designing conversations.</figcaption></figure><blockquote>When dealing with time-sensitive and organisation’s specific information combine LLMs with vector databases, graph databases, and document stores to <strong>generate</strong> <strong>grounded</strong> and <strong>truthful</strong> <strong>responses</strong>.</blockquote><p>Generative AI is amazing. This year, as part of my process of learning and testing the technology to report back to you, I’ve tried out a set of generative conversational features built on Dialogflow and Vertex AI. With these features, you can now use large language models to parse and comprehend content, generate agent responses, and control conversation flow. This can significantly reduce agent design time and improve agent quality. But generative AI is not without its problems. A large language model is a type of language model able to achieve general-purpose language understanding and generation. LLMs acquire these abilities by using massive amounts of data to learn billions of parameters during training. Generative AI is the application of a model such as an LLM to generate text based on user input, and it does this by acting as a sort of “word probability machine” based on the corpus that it was trained on. The bad news is that the information used to train an LLM may be weeks, months, or years out of date and in a corporate AI chatbot may not include specific information about the organization’s products or services. That can lead to incorrect responses that erode confidence in the technology.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QkZWbKzMixruRYWHyLaiPw.png" /><figcaption>The information used to train an LLM may be weeks, months, or years out of date.</figcaption></figure><p>In this example, a generalized LLM can provide accurate answers about players, teams, history and rules of a sport in the past. It wouldn’t be able to discuss last night’s game or provide current information about the latest world record or a particular athlete’s injury because the LLM wouldn’t have that information. Given that an LLM takes significant computing horsepower to retrain, it isn’t feasible to keep the model current.</p><p>That’s where retrieval-augmented generation (RAG) comes in. Consider all the information that an organization has — the structured databases, the unstructured PDFs and other documents, the blogs, the news feeds, the chat transcripts from past customer service sessions. In RAG, this vast quantity of dynamic data is translated into a common format and stored in a knowledge library that’s accessible to the generative AI system. The data in that knowledge library is then processed into numerical representations using a special type of algorithm called an embedded language model and stored in a vector database, which can be quickly searched and used to retrieve the correct contextual information.</p><p>Now, say an end user sends the generative AI system a specific prompt, for example, “What is the world record for diving?”. The query is transformed into a vector and used to query the vector database, which retrieves information relevant to that question’s context. That contextual information plus the original prompt are then fed into the LLM, which generates a text response based on both its somewhat out-of-date generalized knowledge and the extremely timely contextual information. Interestingly, while the process of training the generalized LLM is time-consuming and costly, updates to the RAG model are just the opposite. New data can be loaded into the embedded language model and translated into vectors on a continuous, incremental basis. In fact, the answers from the entire generative AI system can be fed back into the RAG model, improving its performance and accuracy, because, in effect, it knows how it has already answered a similar question. In short, RAG provides timeliness, context, and accuracy grounded in evidence to generative AI, going beyond what the LLM itself can provide.</p><blockquote>When we’re designing <strong>conversations</strong> with users, we want to ensure that we are <strong>divergent</strong> when it comes to options and possibilities, and <strong>convergent</strong> when we are trying to help them solve a problem or make transactions.</blockquote><p>Being LLMs typically generalists trained on a large corpus of text, users can prompt or chat with LLMs in a divergent way across a vast range of topics. If you’re actually trying to solve a problem, like reporting a property damage, what seems like creativity and open-ended possibilities might turn into a frustrating user experience.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Csp77qfWcNp4Z6xbgfYLAg.png" /><figcaption>An open-ended chat that always seems to diverge instead of converging towards the problem resolution.</figcaption></figure><p>On the other hand, if we were to only use deterministic intent-based design, our chatbot might get the job done but users would feel like they were conversing with an impersonal robot rather than a helpful assistant. In our daily life we use both <em>convergent</em> and <em>divergent thinking</em>. Convergent thinking focuses on reaching one well-defined solution to a problem. Divergent thinking involves creativity, it helps generate ideas and potentially develop multiple solutions to a problem. Both convergent and divergent thinking are needed for creative problem solving. If we apply these two concepts to LLMs and virtual agents, it is reasonable to believe that the former are more suitable for creative, expressive conversations that help users learn while virtual agents are ideal for focused, problem-solving conversations that can steer users towards their goal. When it comes to critical use-cases, such as reporting a lost passport or requesting to block a stolen credit card, it’s probably not a good idea to “delegate” the whole user-agent interaction to an open-ended LLM. Transactional use-cases are centered around clear and specific intents that often require deterministic prompts to collect and validate structured data needed to trigger actions on the back-end. Missing to detect the user’s intent and to extract the contextual data would inevitably build frustration with the user. In conclusion, since we want to put users’ experience first, for key and sensitive use-cases consider more deterministic approaches instead of delegating free-form NLP tasks (such as intent matching and slot filling) to LLMs.</p><blockquote>Use the <strong>80/20 rule</strong>, or Pareto Principle, to avoid over designing the agent. Then <strong>fallback</strong> to <strong>LLMs</strong> to cover<strong> edge cases </strong>and<strong> common detours</strong> where the unpolished effort may be “good enough”.</blockquote><p>One of the last steps in the detailed design phase of the <a href="https://conversation-design.web.app/">Conversation Design Process</a> is <em>design for the</em> <em>long tail</em>. The <em>head</em> is represented by the key use cases that make 20% of possible paths in a dialog. These are the most important and most common conversational paths that 80% users follow. When we are designing a conversational interface we should focus the majority of our effort on making these paths a great user experience. But there’s a body of common detours (less common, and often less direct or less successful, conversational paths) and a long tail of edge cases (highly uncommon paths) that we cannot disregard or omit as part of the agent design/implementation. Think about all the things that can go wrong in a conversation and all the unexpected or unsupported paths users might take.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ok-SEik_nfpUW7l9f_3Opg.png" /><figcaption>Design for the long tail</figcaption></figure><p>Even with robust intents, there is still room for error. Users may go off script by remaining silent or saying something unexpected. While preventing errors from occurring is better than handling errors after they occur, errors cannot be totally avoided. There are trade-offs in terms of perfection or completeness, and while for detours and edge cases the unpolished effort may be &quot;good enough&quot;, generic static prompts like “Sorry I’m not sure how to help” are just not good enough and we can certainly be a little more specific. Error prompts should be inspired by the <a href="https://conversation-design.web.app/learn-about-conversation/">Cooperative Principle</a> according to which, efficient communication relies on the assumption that there’s an undercurrent of cooperation between conversational participants. Let me give you a real example: recently, in a restaurant in San Francisco I was in the mood for some fruit. I asked the waiter if they had any and the answer was simply “nope”. I then looked at the menu and I noticed a fruit cake dessert. A more efficient communication aimed to address my goal (have fruit) implies a cooperative answer such as “Sorry, we don’t have any fruit on the menu but I can recommend the fruit cake”.</p><p>The <a href="https://cloud.google.com/dialogflow/cx/docs/concept/generative/generative-fallback"><em>generative fallback</em></a> feature uses Google’s latest generative large language models to generate virtual agent responses when end-user input does not match an intent or parameter for form filling. The feature can be configured with a <em>text prompt</em> that instructs the LLM how to respond and the conversation between the agent and the user. The generative fallback feature combined with good flow and intent descriptions can provide agent’s specific and cooperative responses as opposed to generic prompts like “Sorry I’m not sure how to help” or “Sorry, you’ve entered an invalid option”. Error prompts generated by large language models can gently steer users back towards the successful paths or reset their expectations about what is and isn’t possible.</p><p>Let’s look at an example of what happens when we design a virtual agent to be convergent. In this example, the user’s goal is to book a liveaboard for his family. Notice how the agent is not too prescriptive however thanks to LLMs it does handle an unexpected destination as well as the user intent to take a scuba course. It resets the expectations about what is and what isn’t possible and steer the conversation back to the successful path. It’d be extremely hard and almost impossible to design an agent to handle the myriad of unexpected user inputs. That’s when generative AI comes into play.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wylmj5ns3_xus3d9dTY6pQ.png" /></figure><p>Now, let’s put our best practice into action and design a blend of deterministic goal-oriented conversation, and we’ll see how the agent is designed to switch to a generative and LLM-based approach when it’s appropriate. Once the question is answered or the distraction is over, the agent returns to helping the user with their primary goal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OTTvEwf27_eeTGY9ZgXbWw.png" /></figure><p>It is important to highlight that despite generative responses provide good context specific error handling we should always follow <a href="https://cloud.google.com/dialogflow/cx/docs/concept/agent-design#input">agent design best practises</a> related to intents and entities so agents can optimally process the end-user input and avoid raising unnecessary no-matches.</p><blockquote>Inject generative content into your chat and voice bots to <strong>help gain user trust</strong> and make <strong>experiences</strong> a bit more <strong>human</strong>.</blockquote><p>According to the principles of conversation design, defining a clear system persona is vital to ensuring a consistent user experience that builds user trust. Your persona can help provide users with a mental model for what the agent can do and how it works by starting with what users already know. For example, consider the persona behind a chatbot to assist donors with blood donation eligibility questions. It could be modeled after an idealized helpful assistant — empathetic and trustworthy about donors’ needs and sensitive personal information. In this <a href="https://codelabs.developers.google.com/codelabs/dialogflow-generator#0">demo app</a> an LLM determines the user’s eligibility to donate blood by taking the user through a quiz. Below is a generative email crafted by the LLM in the scenario when the person doesn’t exactly meet all the necessary requirements to donate.</p><p><em>Dear [User], Thank you for your interest in donating blood. We appreciate your willingness to help others in need. Based on the information you provided, you are eligible to donate blood. You are within the age range of 18–75, your weight is above 50 kg, and you are not pregnant or have recently given birth. However, you mentioned that you are vegan and your iron levels tend to be low. We would like to inform you that low iron levels can affect your eligibility to donate blood. Hemoglobin is a protein in red blood cells that carries oxygen throughout the body. Iron is necessary for the production of hemoglobin. If your iron levels are too low, you may not be able to donate blood. We recommend that you consult with your doctor to determine if your iron levels are within the acceptable range for blood donation. If your iron levels are low, you may need to take iron supplements to increase your levels before you can donate blood. We appreciate your understanding and look forward to seeing you at one of our centres. Sincerely, [Your Name]</em></p><p>This kind of response makes the user experience feel familiar and intimate. Users are guided by the large corpus of data LLMs are trained on grounded in the content of the organisation’s specific knowledge base.</p><p>Before wrapping up, I would like to mention a few more potential pitfalls to keep in mind when using large language models. Rapid advancements of LLMs have enabled the processing, understanding, and generation of human-like text, with increasing integration into systems that touch our social sphere. Despite this success, these models can learn, perpetuate, and amplify harmful social biases. For example, think about a virtual agent that makes calls to an LLM trained only on the EU GDPR. If the same agent started being used in the US, the model underneath would likely not be <em>fair</em> with potential US users since it has been biased towards the EU regulations. When adopting generative features be mindful that business critical industries like finance, healthcare and, retail are highly regulated when it comes to data-privacy<strong> </strong>and<strong> </strong>fairness<strong>. </strong>Keeping data security and privacy in mind, be also aware of the potential security threats related to LLM-based applications that process very sensitive user inputs since they are subject to <em>prompt injection</em>. While that might be innocent in some cases, it could become harmful if the output is in direct connection with a database or a third-party component. Lastly, learn new adequate strategies to test non-deterministic responses. Very likely the testing strategies that you have been using so far to test traditional deterministic conversational systems are not going to work if those systems now make LLM calls because generative outputs are non-deterministic. Check out <a href="https://cxcli.xavidop.me/">https://cxcli.xavidop.me/</a> to learn about virtual agents testing strategies.</p><p>In conclusion, Large Language Models (LLMs) cannot serve as a drop-in replacement for traditional chatbots and virtual agents. In fact, they complement each other. Only if we keep in mind the fundamental principles of conversation design, as a design language based on human conversation, we will make the most of LLMs and generative AI. The goal is not to trick the user into thinking they’re talking to a human being, but simply to leverage the communication system users learned first and know best: conversation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=193371489f99" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/generative-ai-is-new-and-exciting-but-conversation-design-principles-are-forever-193371489f99">Generative AI is new and exciting but conversation design principles are forever</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What it takes to write a codelab: behind the scenes of my first experience in Developer Relations]]></title>
            <link>https://medium.com/google-cloud/what-it-takes-to-write-a-codelab-behind-the-scenes-of-my-first-experience-in-developer-relations-5f6d4abecfa8?source=rss-55e4556cd81b------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f6d4abecfa8</guid>
            <category><![CDATA[developer-relations]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[codelab]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <dc:creator><![CDATA[Alessia Sacchi]]></dc:creator>
            <pubDate>Fri, 04 Nov 2022 15:45:30 GMT</pubDate>
            <atom:updated>2022-11-08T14:25:27.719Z</atom:updated>
            <content:encoded><![CDATA[<p>I have always been fascinated by Developer Relations. In fact a number of times in my career I think I have acted as a Dev Rel Engineer however I only discovered Dev Rel for the first time in June 2020 while prepping for my interviews. Back then, during lock-down, I had plenty of time to watch YouTube videos and do Qwicklabs: that’s exactly when I stumbled on Developer Advocacy for the first time in my life. In May (almost two years later) the Angular Developer Relations team offered me the fantastic opportunity to support the development of a modern “Getting Started” journey centered around the introduction of Standalone Components in Angular v14. It was my debut :-)</p><p>Heads up: this blog post is <strong>not</strong> about Angular Standalone Components. If you bumped into this blog post while looking for resources to learn about them, roll up your sleeves and do <a href="https://codelabs.developers.google.com/angular-standalone-components?hl=en#0">the codelab</a>! If you decide to keep reading, you will get to know the journey behind it and what in my opinion are the steps needed to publish a <a href="https://codelabs.developers.google.com/">Google Developer Codelab</a>.</p><figure><img alt="This is the app you would build in the codelab" src="https://cdn-images-1.medium.com/max/522/0*9zFAI-DWhQlWdLhp" /><figcaption>This is what you will end up building if you do the codelab ;-)</figcaption></figure><h4>Step 0: get familiar with the technology. Study, practise, experiment.</h4><p>Being standalone components a brand new feature of Angular v14 I needed to figure out myself how standalone components worked. This is not always true for every codelab and often the author is also a subject matter expert. I personally believe we tend to explain more effectively fresh new concepts we have just recently absorbed and understood than others that we had time to digest. My recommendation is no matter how good your technical skills are, take a step back and always be in the shoes of those who will try your codelab. Collect the right resources on the web, study, practise, experiment, learn. What did you find most difficult to understand? What techniques/procedures/methodology did you find beneficial? In your opinion what are the main concepts? The challenges you experienced are likely to be others’ painpoints as well, focus on those ones. When you feel confident move to the next step. In step 1 you will need to find a way to make the learning process you went through much easier for others.</p><h4><strong>Step 1: think carefully about the application you want to build</strong></h4><p>A codelab is a journey itself, for an hour (or longer) your codelab will take the user into an immersive learning experience.</p><blockquote>“Creativity is intelligence having fun” (Albert Einstein)</blockquote><p>Think about the old good days at school: wasn’t the subject you got best marks in also the one you liked the most? If we are more likely to learn when we have fun, then the codelab you want to write shall be engaging from the very beginning till the end. How many samples and how-to are available for the same topic out there? Tons. Sure, the clarity of writing is fundamental however in my opinion there is something more important than that: the story you are going to tell.</p><p>Because I personally struggle to engage anyone when I am not engaged I spent quite some time thinking about the right application. I wanted the webapp to be: 1) straighforward yet effective in getting developers started with Angular standalone components feature 2) informative and interactive 3) catchy and original 4) integrated with some Google Cloud Platform services 4) easy to build and test. The idea came during a meeting with Mark, a great Dev Rel Engineer and the best mentor to support me in this initiative. While talking about interests and hobbies I showed Mark my online <a href="http://alessiasacchi.com/">collection of photos</a> that I had built two years before, I remember seeing him impressed by the images. That sparked the idea of a simple wildlife photo gallery app that also featured a “send message” form to contact the photographer (myself!) and a chat window to learn random facts about the animals pictured in the photos. I had to construct the app with the ultimate goal to highlight and explain others the concepts I had previously learnt. Afterwards, I was going to create “Jimbo” the chatbot in Google Dialogflow CX, integrate it in the application and deploy it to Google App Engine. I couldn’t wait to start coding, prior to that though I needed to write a 1-pager to describe the overall idea to the team and receive inputs.</p><figure><img alt="An extract of the 1-pager I wrote to provide an overview of goals and features of the Photo Gallery app" src="https://cdn-images-1.medium.com/max/759/1*FNPsIT1HNU4rxtkQCVN4tg.png" /><figcaption>An extract of the 1-pager I wrote to provide an overview of goals and features of the photo gallery app</figcaption></figure><h4>Step 2: build a MVP and write a draft of the outline of the codelab</h4><p>Once I got general positive feedback from the team I moved on and I developed an early version of the application. I went through several iterations, for example in my initial design I wanted to use a carousel to display the images. When working on a codelab, something to always keep in mind is simplicity. Everything must be intuitive and simple, in my case the goal was not to get a fancy UI up and running. Time is an important factor to take into consideration, codelabs shouldn’t take hours to complete. Focus on what matters most for the developer. For example, version 1 of the app used a pretty fancy black and white L&amp;F that I borrowed online (see below), the result was a complex and unnecessary CSS for the sake of the codelab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b-zAYLlNJ8gBSeZyhPZBKQ.png" /><figcaption>Version 1 of the app</figcaption></figure><p>Mark and I agreed to adopt a lighter custom UI and show my own photos as they were not under copyright. Furthermore according to the 1-pager and the initial design, the app would have consisted of 3 pages - home, photos and contacts. That was not a good idea either, on the other hand I made the decision to have it all in one page: photos, a “send feedback” form and the chat dialogue. More precisely the form and the chat window were going to be part of the same standalone component which was going to be loaded and visible only when the user clicked on a button. Lazy loading of components in Angular is a common pattern as it reduces the time to load a page, improves performance and enhances the user experience. In a nutshell, when creating a codelab expect to re-iterate over your app many times. As you start building it you will realise the fundamental and necessary features that must be included and what on the contrary can be omitted to simplify the job of learning for the users.</p><p>As the application comes to life it is super important to write down the initial draft of the codelab outline, in other words the structure of the codelab itself. Just like the former, the latter is going to be refined over time and adjusted while writing the codelab.</p><figure><img alt="The initial codelab outline, this changed quite significantly" src="https://cdn-images-1.medium.com/max/837/1*fAmJknOXMrA-LzgRMHgvPQ.png" /><figcaption>Notes of the initial codelab outline, this changed quite significantly.</figcaption></figure><h4>Things to consider</h4><p>You will need to make decisions such as whether or not you want to provide developers with an “intermediate branch”. By giving people an initial scheleton to download, they will be able to invest time on the core topics of the codelab without spending too much time on the preliminary steps to get the early app up and running. While this approach works broadly speaking, there are scenarios (like this one) when it might not be a good idea or applicable at all. At time of writing standalone components are a preview feature of Angular v14, so you must create a brand new application using Angular v14 and then remove the “app module”. By deleting the app module there will be no module left but one component which is the app component that must be declared as standalone. As you realise, refactoring the initial app is not just a pre-requisite but a fondamental step of the codelab itself that can’t be omitted. That’s why for this specific codelab we wanted developers to create the whole application from scratch and the codelab will assist them with that step by step. Having said that the GitHub repo contains the complete source code to follow along in case they get stuck as well as the images displayed on the gallery page.</p><h4>Step 3: write the codelab</h4><p>Once the app was finalised I started authoring the codelab. Every codelab should start with an introduction which usually includes the following three sections: what you will build, what you will learn, what you will need (such as the development environment needed to build the artifacts or an existing account and the subjects for which a basic knowledge is important). If users are expected to write code, the introduction is usually followed by the environment setup (which outlines the software required to complete the lab) and the GitHub repository. As explained before, depending on goals and scenario, the repository might have two separate branches: one branch with the complete source code and an “intermediate branch” which normally provides an initial starter application on top of which developers will build the rest of the app. Every main section of a codelab should provide a racap of what’s been done until that point and more importantly a brief introduction of what’s coming next and why. The “why” is essential otherwise the codelab will turn into an arid list of steps and actions without a sense of direction. Remember, the ultimate goal is to simplify and streamline the learning curve of a pretty complex subject for the users. Don’t take anything for granted, be explicit and cristal clear. The person who is reading doesn’t have your same knowledge of the matter and context. Use the right terminology and provide images to support your wording, often a screenshot is a lot more intuitive and powerful than a lot of words. Furthermore, for clarity I always recommend to show the complete code example at the end of a series of snippets. Lastly, remind the user to save changes and test as frequently as possible. At last but not least, do you remember when earlier on I stressed the importance of creativity and user engagement when composing a codelab? Find something that can spice it up and hook them in. Give developers something to play and maybe interact with. Add gamification to your codelab, it can be as simple as learning cool facts about sharks and other wild animals through a koala made chatbot!</p><h4>Step 4: test and then test it again!</h4><p>Testing is vital, it is absolutely necessary to test a codelab many times while creating it and afterwards during the review process. Once I completed the first version I proceeded to test every step pretending to be a developer who had never seen the codelab before. I followed it line by line, created and deployed the photo gallery app from scratch and edited the codelab whenever I found something incomplete or not clear enough. Peer reviewing is essential, I asked Mark to test it all out for me to discover any bugs and to get his thoughts around my wording. A Google Developer Codelab goes through a very diligent review process which involves engineering and copywriters. Product engineers will improve and enhance the code while copywriters will focus on wording and writing. Every change to either the source code or the codelab can introduce regression bugs. It’s the author’s responsability to merge any changes carefully to ensure consistency. When the codelab is ready to be staged and finally published, the last couple of steps require converting the codelab from a gDocs document into a web viewable format and checking the source code into a Google official GitHub repository.</p><p>In conclusion, a codelab is a product of the imagination which requires creativity, time and dedication. Its primary goal is to create a well-lit path forward for developers to learn a specific topic. I believe every learning experience should be inspiring in order to be successful. I wrote the “Getting started with Standalone Components” <a href="https://codelabs.developers.google.com/angular-standalone-components?hl=en#0">codelab</a> keeping that principle in mind. Feedback is a gift, try it and let me know what you think!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f6d4abecfa8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/what-it-takes-to-write-a-codelab-behind-the-scenes-of-my-first-experience-in-developer-relations-5f6d4abecfa8">What it takes to write a codelab: behind the scenes of my first experience in Developer Relations</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Verba volant, scripta manent. Experimenting with Dialogflow Messenger and BigQuery]]></title>
            <link>https://medium.com/google-cloud/verba-volant-scripta-manent-experimenting-with-dialogflow-messanger-and-bigquery-18f6e5c031c1?source=rss-55e4556cd81b------2</link>
            <guid isPermaLink="false">https://medium.com/p/18f6e5c031c1</guid>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[conversational-ai]]></category>
            <category><![CDATA[voice-assistant]]></category>
            <category><![CDATA[dialogflow]]></category>
            <dc:creator><![CDATA[Alessia Sacchi]]></dc:creator>
            <pubDate>Wed, 30 Mar 2022 16:33:43 GMT</pubDate>
            <atom:updated>2023-02-28T13:28:14.036Z</atom:updated>
            <content:encoded><![CDATA[<p>I am under the impression that voice agents are having a much bigger moment than chatbots similarly to how a few years ago bots cast a shadow over mobile apps and before then mobile apps shadowed web apps. Speaking of trends if texts have eclipsed phone calls, voice messages have surpassed texts. In a terrific <a href="https://www.theguardian.com/technology/2018/dec/02/five-reasons-why-voice-messaging-is-the-next-big-thing">article</a> published on the Guardian in December 2018 Chris Stokel-Walker identified voice messaging as the next big form of communication. During the COVID-19 pandemic <a href="https://blog.whatsapp.com/group-video-and-voice-calls-now-support-8-participants/?lang=en">over 15 billion minutes</a> of voice and video calls were made on WhatsApp every day.</p><blockquote>Always consider the listener. At least in a real-time phone call, it’s possible for the other side to cut in on the chat about your latest tiff with Tiffany from HR. Chivvying along conversations isn’t possible if you’re giving a recorded monologue, so keep it brief and to the point. Or better yet, ask yourself whether it needs to be said at all. No one likes to sit through a five minute sub-Shakespearean soliloquy. (<a href="https://www.theguardian.com/profile/chris-stokel-walker"><strong>Chris Stokel-Walker</strong></a>)</blockquote><p>In this post I would like to analyze pros and cons of voice vs text in the context of Conversational Interfaces, why often text is a better channel of communication with a virtual agent. We will then explore a simple <a href="https://20220321t113831-dot-diaologflow-cx-playground.uc.r.appspot.com/">chatbot</a> that writes data into a BigQuery table and we will look at how we can embed it into a web page running in App Engine through a customizable chat dialogue using Dialogflow Messenger.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DuUbViWwLH7mHHvB.jpg" /><figcaption>Virtual or human, always consider the listener. They’re called instant messages for a reason :-)</figcaption></figure><h3>Let’s start from the beginning: voice vs texts</h3><p>Why did voice messages become so popular? I guess because they are somehow in between phone calls and texts. They allow for quick communication like phone calls but they’re less “intrusive” than phone calls. Calling is seen by some as an intrusion - forcing people to talk to you when they might not be ready or prepared. Anecdotal evidence suggests that we have grown scared of picking up the phone. We’re in touch with each other constantly, but written communication allows us to participate in the conversation at the pace we choose. Voice messages allow to communicate asynchronously (as opposed to phone calls) but they are less impersonal and “aseptic” than text messages. Voice communication gives a really rich sense of emotion and a higher sense of connection, you can get the sense of things across better with the tone of your voice, rather than relying on emojis.</p><blockquote>How many times did you get in trouble with text?</blockquote><p>In a few words voice messaging provides the best of both worlds. It is asynchronous like texting yet more emotive and more spontaneous than text-based communication. If you send a voice message, you can still continue to use your phone, or do other things (have you ever recorded a voice message while driving? ;-)). Having said that receiving a voice message might be less convenient than sending one: very often (especially if we are in a room with other people) we cannot listen to the audio unless we use headphones. If a text pops up on your screen you can quickly tell whether or not it’s urgent. If the only clue you have is a picture of an indistinct sound-wave, you don’t know if that message needs your attention right away or can wait until you have a spare minute. Thinking about the disadvantages of voice vs text we shall not forget that people sitting or standing or walking near us are not interested in our chats, we shall be mindful of the circumstances and use text-based communication when it’s more appropriate. Lastly, as mentioned in the caption of the image always consider the listener and be respectful of their time. Voice messages tend to be more verbose than texts, simply because it takes less time to speak than typing on a small keyboard.</p><h3>Chatbots vs voicebots: the insoluble dilemma</h3><p>Is it really an insoluble dilemma? I don’t think it is. Why? Because the answer is often in the use case we need to implement. Don’t seek a use-case for the technology you want to use - choose the right technology to address a real use-case. I have seen overwhelming and chaotic mobile apps that should have been easy-to-navigate web apps and robotic conversational interfaces in place of nice and visual mobile applications. I am afraid we are seeing a similar trend for voicebots and chatbots. The former are becoming more and more popular, companies are investing a lot of money to migrate traditional Interactive Voice Response systems into Conversational Contact Centers.</p><p>Let’s dive into the strengths both of these conversational interfaces bring to the table.</p><h4>When should you consider a voicebot?</h4><p>With voicebots, you can communicate with the AI just by speaking to it. Voicebots are ideal for people of all demographics and age groups. The ease of use makes it easy even for those who aren’t particularly tech-savvy to use the bot and still have a great experience. Voicebots work like speaking to someone over a telephone call, just like dialling a number on the phone. Voicebots don’t need messaging platforms as opposed to chatbots, neither they need to be integrated with the company website or mobile-app. From a customer experience perspective it is as easy as picking up the phone, dialing a number and speaking with a human agent. Voice can be a strategy to delight customers. When people hear a voice, they instantly make assumptions about the speaker’s gender, age, social status, emotional state, and place of origin, as well as personality traits like warmth, confidence, intelligence, etc. People can’t help but do this with virtual assistants, too. When creating a “persona” for their virtual agents companies can hire professional voice actors and choose the best voice by holding an audition. Why? Because a recorded voice is a lot more natural, expressive and human than a synthesized one. It can convey humor, sarcasm, trust and ultimately turn a virtual assistant into a conversational partner. At last but certainly not least voice is an assistive technology for visually impaired or blind people. Broadly speaking voice helps people in situations when their hands or eyes are occupied, or when they’re on the move. When we carry a shopping bag or when we drive or when we are busy cooking etc, in these or similar circumstances we all experience a sort of impairment and voice becomes the best communication channel.</p><h4>When should you consider a chatbot?</h4><p>Voice is a powerful approach, but it’s not always the right choice for every use-case. For example, it works well for the task of finding a restaurant’s business hours, but it feels clunky for browsing a dinner menu. Voice is the right approach when the interaction with the user is brief, with minimal back-and-forth dialog. On the other hand chatbots are excellent for working through complex chat flows. It is ideal for non-linear user journeys where the chatbot displays many options that need not be remembered. Chatbots simplify complicated use cases with user-friendly interfaces. Back to the previous example, the results of a flight search could be displayed in a chat dialogue as a list of items and a retail chatbot could show the user the last black dresses remained in stock though a carousel of images. FAQ bots often provide users with phone numbers to call, email addresses, URLs and the end-user might have to navigate a web site to complete a task. In these circumstances they might need to look back at the messages sent by the chatbot and a voicebot due to its transient nature (as the title of this blog post suggests) simply cannot do it. Avoid very long responses, if you can’t help that (for example, FAQ bots provide a lot of information) then opt for a chatbot. Furthermore chatbots support custom rich info response types like buttons, accordion panels, suggestion chips, audio-visual media like pictures, videos, GIFs and more. The combination of these features can make the experience richer and more engaging, on the contrary voicebots are confined to audio-based media. To determine whether a voicebot is the right strategy for your use case consider whether your users would feel comfortable talking or typing about certain topics. Spoken conversations are best in private spaces or familiar shared spaces. Written conversations are best for personal devices.</p><p>To summarize there is no one size fits all answer to this question. If you’re wondering which one is better between chatbots vs voicebots — it depends on what works the best for your customers and the kind of issues you are planning to solve at hand. An excellent way to find the sweet spot for your business is by finding the overlap between your business’s goals and your users’ goals. Other considerations include the level of engagement, volume of information to be transmitted, the types of media that can be used and whether the user journey is linear or nonlinear. My advice is to review the <a href="https://developers.google.com/assistant/conversation-design/is-conversation-the-right-fit">following statements</a> to determine whether conversation design is the right strategy for your features in the first place. If you’re checking off most of them, it’s likely that dialog is a good fit. If conversation is the right fit, then think carefully if voice can add value to your use case or not.</p><h3>Fantasia: an experiment with Dialogflow Messenger and BigQuery</h3><p>Now open up this <a href="https://20220321t113831-dot-diaologflow-cx-playground.uc.r.appspot.com/">page</a>, click the blue chat icon at the bottom right and give it a try!</p><p>Before diving into the technicalities let me make a step back and give you some context. Some time ago Ivan and I needed to collect some data to train a ML model to predict helpdesk issues resolution times instead of using an existing dataset available on GitHub. By the way do yourself a favour and read this great <a href="https://medium.com/google-cloud/boost-up-a-helpdesk-chatbot-with-dialogflow-cx-tfx-and-vertex-ai-4999c26eef13">article</a> written by Ivan to learn about the whole idea.</p><p>I thought a good way to produce random data was through a Chatbot that presented users with a set of questions and wrote the answers into a BigQuery table that had the same schema of the Helpdesk Issues dataset. I also had to choose a channel to let people interact with it. The channel meaning the platform that will allow your users to interact with the bot depends a lot on who they are and the needs they have. Try to answer questions like the following:</p><ul><li>Who are my users?</li><li>What are their needs?</li><li>How are they completing these tasks today?</li><li>What words and phrases do they use to talk about these tasks?</li><li>What situations or circumstances trigger these tasks?</li></ul><p>While it’s important to optimize for your most frequent users, don’t do so at the expense of other users’ experiences. A well-designed product is inclusive and universally accessible. Designing for different populations means leveraging <em>inclusive design</em> or <em>universal design strategies</em>. The channel you will end up choosing should be as inclusive as possible.</p><p>Back to my little chatbot, I decided to use Dialogflow Messenger and embed it in a simple page hosted in App Engine. Dialogflow CX supports a number of built-in text based integrations and are configured with the Dialogflow Console like Facebook Messenger. The Dialogflow Messenger integration provides a customizable chat dialog for your agent that can be embedded in your website. If you’ve played with “Fantagent” you have noticed the chat dialog is implemented as a dialog window which appears in the lower right side of the screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SngU0dO8vO7QYZJNsgkH_w.png" /><figcaption>Give it a chat!</figcaption></figure><p>You can customize various aspects for how the chat dialog appears and behaves. The df-messenger HTML element has a number of attributes like the chat-title and a first initial intent that shall be triggered when the chat dialog is opened (like the greeting message displayed above).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pixpnWmG1zNXvbNyz5yf3A.png" /><figcaption>The &lt;script&gt; and &lt;df-messenger&gt; HTML elements should be in the &lt;body&gt; element of your page</figcaption></figure><p>If you’ve actually made it to the end of the dialogue you would have come across a widget to show all the possible categories and let the user select one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*_OCuKNpFzh0HC8btqXnTog.png" /><figcaption>The list response type is a card with multiple options users can select from.</figcaption></figure><p>This widget is a <a href="https://cloud.google.com/dialogflow/cx/docs/concept/integration/dialogflow-messenger#list_response_type">List response type</a>, a card with multiple options users can select from. When creating <a href="https://cloud.google.com/dialogflow/cx/docs/concept/fulfillment">fulfillment</a>, you can create <strong>Text Responses</strong> and <strong>Custom Payloads</strong> . The text responses are used for basic agent responses, and the custom payloads are used for rich responses. Custom payloads can be returned from a webhook (as part of the webhook response) for dynamic responses or they can be configured in the fulfillment section of a page when designing the agent through the console. See the code below for the custom payload. When the user clicks an option from the list a <a href="https://cloud.google.com/dialogflow/cx/docs/concept/handler#event">custom event</a> is triggered which allows me to identify the user choice.</p><pre>{<br>  &quot;richContent&quot;: [<br>    [<br>      {<br>        &quot;type&quot;: &quot;list&quot;,<br>        &quot;event&quot;: {<br>          &quot;languageCode&quot;: &quot;&quot;,<br>          &quot;parameters&quot;: {},<br>          &quot;name&quot;: &quot;Authentication&quot;<br>        },<br>        &quot;subtitle&quot;: &quot;If you can&#39;t login or you&#39;re having issues signing in&quot;,<br>        &quot;title&quot;: &quot;Authentication&quot;<br>      },<br>      {<br>        &quot;type&quot;: &quot;divider&quot;<br>      },<br>      {<br>        &quot;type&quot;: &quot;list&quot;,<br>        &quot;title&quot;: &quot;Billing&quot;,<br>        &quot;event&quot;: {<br>          &quot;name&quot;: &quot;Billing&quot;,<br>          &quot;parameters&quot;: {},<br>          &quot;languageCode&quot;: &quot;&quot;<br>        },<br>        &quot;subtitle&quot;: &quot;If you have a billing enquiry&quot;<br>      },<br>      {<br>        &quot;type&quot;: &quot;list&quot;,<br>        &quot;title&quot;: &quot;Performance&quot;,<br>        &quot;event&quot;: {<br>          &quot;parameters&quot;: {},<br>          &quot;languageCode&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;Performance&quot;<br>        },<br>        &quot;subtitle&quot;: &quot;If you&#39;ve seen a degradation of performance&quot;<br>      },<br>      {<br>        &quot;type&quot;: &quot;list&quot;,<br>        &quot;subtitle&quot;: &quot;For any technical issues&quot;,<br>        &quot;title&quot;: &quot;Technical&quot;,<br>        &quot;event&quot;: {<br>          &quot;languageCode&quot;: &quot;&quot;,<br>          &quot;name&quot;: &quot;Technical&quot;,<br>          &quot;parameters&quot;: {}<br>        }<br>      }<br>    ]<br>  ]<br>}</pre><p>Once all the values have been collected a webhook call is done to a Cloud Function to write a record into a BigQuery table through the <a href="https://cloud.google.com/nodejs/docs/reference/bigquery/latest">Google BigQuery Node.js Client API</a>. I highly encourage you to check out this great Google BigQuery Client <a href="https://github.com/googleapis/nodejs-bigquery">Library</a> for Node.js which includes a number of samples including the insertRowsAsStream() function which I used to write the data passed from the bot to the Cloud Function into a dedicated BigQuery table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HPbF8S-BnyjlPnnqs3VYLg.png" /></figure><h3>Conclusions</h3><p>Conversation design is a powerful approach, but it’s not right for every use case. After you have determined a Conversational Interface is the right fit think carefully about the channels of engagement. A good conversation design process starts by gathering the requirements. Gathering requirements for a conversational experience is not just about defining features and functionality, though that is the main outcome. Starting with clear, well-researched requirements is the best way to avoid the need for major changes after design and/or development is completed.</p><p>Thanks for reading through the end and until my next post!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18f6e5c031c1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/verba-volant-scripta-manent-experimenting-with-dialogflow-messanger-and-bigquery-18f6e5c031c1">Verba volant, scripta manent. Experimenting with Dialogflow Messenger and BigQuery</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Google Maps Places API to “validate” locations in a conversation with a virtual agent]]></title>
            <link>https://medium.com/google-cloud/using-google-maps-places-api-to-validate-locations-during-a-conversation-with-a-virtual-agent-ebd5efcdf9e5?source=rss-55e4556cd81b------2</link>
            <guid isPermaLink="false">https://medium.com/p/ebd5efcdf9e5</guid>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[google-maps]]></category>
            <category><![CDATA[gcp-app-dev]]></category>
            <category><![CDATA[conversational-ai]]></category>
            <category><![CDATA[dialogflow]]></category>
            <dc:creator><![CDATA[Alessia Sacchi]]></dc:creator>
            <pubDate>Wed, 12 Jan 2022 11:44:29 GMT</pubDate>
            <atom:updated>2022-08-18T14:41:45.816Z</atom:updated>
            <content:encoded><![CDATA[<p>Less than a couple of months ago I wrote an <a href="https://medium.com/google-cloud/using-dialogflow-cx-composite-entities-to-work-around-system-entities-limitations-c6385df12f2b">article</a> to describe how Dialogflow CX system entities @sys.date and @sys.time can be combined into custom composite entities to workaround a quirk of @sys.date-time when used with the Italian language. Today I would like to take you with me on a trip around the globe! Unfortunately I won’t be assisted by system entities like @sys.geo-city and @sys.locationas they are not yet available in non-US and non-global regions. What that means is for agents deployed outside of US we cannot leverage them to match things like a zip code, a full address, street names, cities, countries, airport names, etc. So, how do we work this out? Well, here is when the Places API of Google Maps comes into play so sit back and enjoy the ride!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BpjHHwArjwrlDFiq_i0HzA.jpeg" /><figcaption>Above all my favourite one :-)</figcaption></figure><h3>What are we trying to achieve?</h3><blockquote>Hi, are there any trains to <strong>San Franc</strong> tonight?</blockquote><p>Short answer: we want to be able to extract the string “San Franc” from the above sentence. Actually let me make a step back: to help our user get to San Francisco tonight our agent should first resolve the intent and contextually extract any meaningful pieces of information like <strong>San Franc</strong> and <strong>tonight</strong>. These are what in Natural Language Understanding we call <em>entities, </em>you can think of them as subject matter experts or simply <em>slots</em> that we need to fill in with values from specific parts of the end-user input.</p><p><em>Entity types</em> are used to control how data from end-user input is extracted. Dialogflow provides predefined <a href="https://cloud.google.com/dialogflow/cx/docs/concept/entity-system">system entities</a> that can match many common types of data. For example, there are system entities for matching dates, times, colors, email addresses, and of course locations. If we had to build an agent to help users find/book trains in Dialogflow CX we would start from creating the intent <em>head.findTrains. </em>To create an intent we must provide a set of training phrases (also called utterances in NLU) which are example phrases for what end-users might type or say. When end-user input resembles one of these phrases, Dialogflow matches the intent. You control how end-user data is extracted by <em>annotating</em> parts of your training phrases. When you annotate parts of a training phrase, Dialogflow recognizes that these parts are just examples of actual values that will be provided by end-users at runtime. For an end-user input like “Are there any trains to <strong>San Franc</strong> tonight?”, Dialogflow would extract the date-time parameter from &quot;tonight&quot; and the destination parameter from &quot;San Franc&quot;.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*1if36xSfzkR_1dUgXmFX9A.png" /><figcaption>How Dialogflow annotates training phrases</figcaption></figure><p>Easy … if @sys.location or @sys.geo-city were available in non-US &amp; non-global regions as well ;-) Unfortunately at time of writing they are only available for agents deployed in the US. So, that’s exactly the issue we are trying to solve: we need to extract “San Franc” <strong>and</strong> validate it’s a <strong>legitimate</strong> city. By the way, have you noticed I didn’t say “San Francisco”, instead I am using the Aussie version which is “San Franc”? Similarly I do expect inputs like “NYC” or “San Dieeego” aren’t ignored because they don’t match exactly with the original names of the cities of New York City and San Diego. In fact they must be extracted from the user sentence and resolved into their actual names (New York City and San Diego). There is more though: I was born in “Ascoli Piceno” a lovely city in the centre of Italy which is normally referred to as “Ascoli”. To make things slightly complicated there is another place in Italy called “Ascoli Satriano”. For an end-user input like “Are there any trains to <strong>Ascoli</strong> tonight?” the perfect user-experience driven by the cooperative principle wants the agent to follow up with a question like “Did you mean Ascoli Piceno or Ascoli Satriano”?</p><p>As usual there isn’t just one solution to solve the problem, we can think of at least two or three ways to address all these requirements. We could create a complex custom entity from the list of all cities in the US (don’t forget synonyms…), or once we have extracted the location from the end-user input we could perform a “lose search” against a system of records (just keep in mind this is natural language so string matching doesn’t work well!). Option 3: we could leverage what the Geography system entities actually use under the hood… Google Maps!</p><h3>Introducing the Places API</h3><p>The Google Maps Platform offers an astonishing set of SDKs and APIs for Maps, Routes, and Places. Specifically the Places API &amp; SDKs allow developers to integrate Google’s Place details, search, and autocomplete into their applications. The Places API is a service that returns information about places using HTTP requests. Places are defined within this API as establishments, geographic locations, or prominent points of interest. Google Maps Platform products are secured from unauthorized use by restricting API calls to those that provide proper authentication credentials. These credentials are in the form of an API key, a unique identifier that authenticates requests associated with your project for usage and billing purposes. Check out this <a href="https://developers.google.com/maps/documentation/javascript/get-api-key">link</a> to know how you can generate your own API key and include it with every Maps JavaScript API request.</p><p>The Place Autocomplete service is a web service that returns place predictions in response to an HTTP request. The request specifies a textual search string and optional geographic bounds. The Place Autocomplete service can match on full words and substrings, resolving place names, addresses, cities, codes, etc. You can instruct the Place Autocomplete service to return only geocoding results, rather than business results. You may restrict results to be of a certain type by passing thetypes parameter and among the types supported in place autocomplete requests we also find the(cities) type collection which instructs the service to return results that match locality or administrative_area_level_3. This specific type (and a few more) are not supported by other services like Find Place hence my decision to use the Place Autocomplete service for my use case.</p><p>Let’s look at an example, a request for cities containing the string “Ascoli”:</p><pre>https://maps.googleapis.com/maps/api/place/autocomplete/json<br>  ?input=Ascoli<br>  &amp;types=(cities)<br>  &amp;language=it<br>  &amp;components=country:it<br>  &amp;key=YOUR_API_KEY</pre><p>The <em>input p</em>arameter is required to initiate a Place Autocomplete request and it is the text string on which to search. The Place Autocomplete service will return candidate matches based on this string and order results based on their perceived relevance. There are other optional parameters like <em>language</em> in which to return results or the list of countries if you need to restrict your results to places within certain countries. In this example I am restricting results to be cities in Italy that match the string “Ascoli”.</p><p>Here is a a fragment of the response returned in the JSON format (you can choose between JSON and XML). For simplicity I have only included the first two predictions (2 of 3) and I have removed sections from the response. As expected the Place Autocomplete service returns “Ascoli Piceno” followed by “Ascoli Satriano”.</p><pre>{<br>   &quot;predictions&quot; : [<br>      {<br>         &quot;description&quot; : &quot;Ascoli Piceno, Province of Ascoli Piceno, Italy&quot;,<br>         &quot;matched_substrings&quot; : [<br>            {<br>               &quot;length&quot; : 6,<br>               &quot;offset&quot; : 0<br>            }<br>         ],<br>         ....<br>         &quot;types&quot; : [ &quot;locality&quot;, &quot;political&quot;, &quot;geocode&quot; ]<br>      },<br>      {<br>         &quot;description&quot; : &quot;Ascoli Satriano, Province of Foggia, Italy&quot;,<br>         &quot;matched_substrings&quot; : [<br>            {<br>               &quot;length&quot; : 6,<br>               &quot;offset&quot; : 0<br>            }<br>         ],<br>       ....<br>   &quot;status&quot; : &quot;OK&quot;<br>}</pre><p>You can be as detailed as you want and add the region or the state or the postcode for the city you are looking for (e.g: “San Francisco California”, “Ascoli 63100”). You can use acronyms like “NYC” or colloquial names like “San Franc” or misspell the world: they are all possible inputs when using Natural Language and our conversational system must be able to resolve and validate them. If the search is successful but no matches are found than the service will returnZERO_RESULTS status code.</p><h3>The Webhook</h3><p>I have chosen to implement the webhook invoked by the agent using Node.js and run it on Google Cloud Functions. Quick introduction, <a href="https://cloud.google.com/dialogflow/cx/docs/concept/webhook"><em>Webhooks</em></a> are services that host your business logic. During a session, webhooks allow you to use the data extracted by Dialogflow’s natural language processing to generate dynamic responses, validate collected data, or trigger actions on the backend.</p><p>What does this webhook do? It invokes the Places API Autocomplete service passing in input the destination extracted by Dialogflow from the end-user input (we will look at how to extract the location from the user intent in the next paragraph). From the webhook prospective “destination” is a parameter set by Dialogflow in the webhook request message as part of the call. <em>Parameters</em> are used to capture and reference values that have been supplied by the end-user during a session. Each parameter has a name and an entity type. Intents use parameters to extract data provided by end-users when intents are matched, in this particular scenario when an end-user input matches the “head.findTrains” intent at runtime, any parameter used by an annotation for the associated training phrases is set by Dialogflow. For this intent we can reasonably expect the destination where the user wants to go, the departure place as well as the date and time. For the scope of this PoC I will just focus on the destination, ultimately the logic that applies to destination would also apply to departure place.</p><p>At run-time the fulfilment for the intent route sets the “destination” parameter value that the function receives and reads from the webhook request:</p><pre>if (!(req.body.intentInfo &amp;&amp; req.body.intentInfo.parameters)) {<br>return res.status(404).send({ error: &#39;Not enough information.&#39; });<br>}</pre><pre>let destination = req.body.intentInfo.parameters[&#39;destination&#39;].originalValue;</pre><p>We can now initiate a Place Autocomplete request as an HTTP URL of the form below. As is standard in URLs, all parameters are separated using the ampersand (&amp;) character. Note, we are narrowing down the search to only cities in US and don’t forget to replace the key in this example with your own API key in order for the request to work in your application!</p><pre>var config = {</pre><pre>method: &#39;get&#39;,</pre><pre>url: &#39;https://maps.googleapis.com/maps/api/place/autocomplete/json?    input=&#39; + destination + &#39;&amp;types= (cities)&amp;language=en&amp;components=country:us&amp;key=YOUR_API_KEY&#39;,</pre><pre>headers: { }</pre><pre>};</pre><p>I have used Axios to make the HTTPS request from the node application. Axios is a <a href="https://javascript.info/promise-basics"><em>promise-based</em></a> HTTP Client for node.js and the browser. It is <a href="https://www.lullabot.com/articles/what-is-an-isomorphic-application"><em>isomorphic</em></a> (= it can run in the browser and nodejs with the same codebase). On the server-side it uses the native node.js http module, while on the client (browser) it uses XMLHttpRequests. To use Axios for node I first installed it using <em>npm install </em>and then imported with require() using the following approach:</p><blockquote>const axios = require(‘axios’);</blockquote><p>To perform the GET request to the Place Autocomplete service using Axios I have used this approach:</p><pre>axios(config)<br> .then(function (response) {</pre><pre> //handle success (including ZERO_RESULTS)</pre><pre> })   <br> .catch(function (error) {     <br> <br> // handle error  </pre><pre> })   <br> .then(function () {     // always executed  <br>});</pre><p>If the invocation to the API is successful and the service finds matches for the given input I use a for-loop to iterate through the array of predictions returned in the response and create a second array containing just the description of each prediction.</p><pre>axios(config)<br> .then(function (response) {</pre><pre> //handle success (including ZERO_RESULTS)<br> if(response.data.predictions.length &gt; 0) {</pre><pre>  for(var i in response.data.predictions){<br>   var prediction = response.data.predictions[i].description;<br>   predictions.push(prediction);</pre><pre>...</pre><p>Why do I create a second array? Well, the explanation is a bit long but I promise, I will get there! To start with, there are three possible outcomes that we need to handle if the service doesn’t return an error:</p><p><strong>Case 1: no match </strong>(ZERO_RESULTS indicates that the search was successful but returns no results. This may occur if the search was passed a location that doesn’t exist). What should the user experience be? “<em>Conversation repair is the practice of fixing misunderstandings, mishearings, and misarticulations to resume a conversation. Repairing a conversation can help build a user’s trust by showing that the agent is listening to their request”. </em>Repeat the question to the user, but rephrase it in a shorter way to indicate the information that is missing.<em> </em>I think these are all valid prompts for the first no match: “Sorry, which city?”, “Sorry, you’re traveling to which city?”.</p><p><strong>Case 2: single match.</strong> The service returned one single location (I have noticed this happens when the search is passed the zip code or the state where the city is located other than the city itself). What should the user experience be? A single match here is like ace in tennis ;-) The Places API has validated the destination is legitimate, as a next step the agent will be providing the customer with a timetable of trains to fulfill the request.</p><p><strong>Case 3: multiple matches</strong> (multiple predictions are returned). This third scenario is in my opinion the most likely one. According to the Autocomplete service documentation</p><blockquote>The Place Autocomplete service will return candidate matches based on this string and order results based on their perceived relevance.</blockquote><p>Based on that with a high degree of confidence we can say that the first prediction of the list is very likely the city where the user wants to go. What if it is not? What if by saying “Ascoli” the user didn’t mean “Ascoli Piceno” (first prediction in the list), in fact he meant “Ascoli Satriano” (second prediction). What would a good user experience be in this third path? I think the agent should ask the user an explicit and actionable question like “Just to confirm, did you mean Ascoli Piceno?”. They could confirm the agent’s guess or contradict it by saying “No, Ascoli Satriano” (this second location matches the second item in the array, loop is closed) or just “nope” (in this case the agent should just cooperate with the user by presenting the other possible matches). Either way the array of predictions helps move the conversation forward hence the reason why the webhook application creates a second array and writes it to the session (as a session parameter) that we can reference at any point during the conversation with the user.</p><p>To summarise, depending on the output returned by the Place Autocomplete service the webhook adds the predictions array to the session info, sends a different message back to the agent (in the fulfilment response) and transitions to a different target page.</p><pre>res.status(200).send({<br> sessionInfo: {<br>  parameters: {<br>   predictions: predictions<br>  }<br> },<br> fulfillmentResponse: {<br>  messages: [{<br>   text: {<br>    text: [agentMessage]<br>   }<br>  }]<br> },<br> targetPage: targetPage<br>});</pre><p>For example if the service returns more than one prediction the flow will transition to the page “Multiple Matches” and the below message will be shown to the user.</p><pre>targetPage = &quot;projects/diaologflow-cx-playground/locations/us-central1/agents/5b0d10a9-8bca-49f2-bb17-50144df939e0/flows/00000000-0000-0000-0000-000000000000/pages/9d9b5bb1-2979-4462-b4bf-115513b1d6d5&quot;;</pre><pre>agentMessage = &quot;Just to confirm, did you mean &quot; + predictions[0] + &quot;?&quot;;</pre><h3>The Agent</h3><p>How do we blend this into Dialogflow CX? Earlier before I explained that what is sent to the Places API is what Dialogflow has previously extracted from the end-user input when it matches the “head.findTrains” intent at runtime. Any parameter used by an annotation for the associated training phrases of the intent is set by Dialogflow and added to the list of intent params for the webhook. Check out this <a href="http://You control how end-user data is extracted by annotating parts of your training phrases and configuring the associated parameters.">link</a> to see how in Dialogflow CX you can <em>annotate </em>parts of your training phrases and configure the associated parameters. When you annotate parts of a training phrase, Dialogflow recognizes that these parts are just examples of actual values that will be provided by end-users at runtime. For an end-user input like “<em>Are there any trains that can take me to NY tomorrow?</em>”, Dialogflow would extract the date-time parameter from &quot;tomorrow&quot; and the destination parameter from &quot;NY&quot;. When building an agent with the console, most annotations are automatically created for you when you add training phrases that contain parts that can be matched to an existing <a href="https://cloud.google.com/dialogflow/cx/docs/concept/entity">entity type</a>. These parts are highlighted in the console for you. The great thing though is the fact you can annotate words as needed meaning despite “NY” can’t be matched to the existing @sys.geo-city system entity (because it’s not available outside of US regions) you can still instruct Dialogflow to recognise this part of the sentence. By providing a reasonable number of training phrases and annotating them accordingly you will train the NLU engine to recognise not just date-time but also destination as key-words and extract them from the end-user input at runtime.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V9bp_v3aMiYDxGVP25nbdw.png" /><figcaption>You control how end-user data is extracted by <em>annotating</em> parts of your training phrases</figcaption></figure><p>The simulator in Dialogflow CX is a great way to test things out. So let’s see what the engine extracts from an end-user input like “Are there any trains to Boston tonight?”. Ignore what the agent says right now, we will look at that in a bit. What I wanted to highlight here are the two intent parameters (date-time and destination) that Dialogflow has identified and extracted. They are now ready to use ;-)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/993/1*Jln3svV3KtBDtMYKaQThaw.png" /><figcaption>The Simulator, what a great way to rapidly test and debug!</figcaption></figure><p>When the end-user input matches the “head.findTrains” intent at runtime we want trigger a request to the webhook and all the magic will follow as per the implementation of the cloud function :-)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*v-z3PKTiDYaX--4HBW_8mg.png" /><figcaption>The intent route will be fulfilled by a webhook call to the findPlace function running in GCF</figcaption></figure><p>So what happens now? When the webhook receives the request from Dialogflow first it reads the destination parameter value and after trimming/removing any invalid characters/lower casing it calls the Place Autocomplete service. In our example the destination entered by the user is Boston and it turns out that there are five Boston in the US. The webhook parses out the Place Autocomplete response and finds five predictions as shown by the <em>predictions</em> array . We are in the “Multiple Matches” scenario and while there’s a great chance that the user is referring to the city of Boston in Massachusetts we should not assume and therefore we want to check that. Once completed the webhook sends a 200 OK fulfilment response back to Dialogflow with the following instructions: transition to the page “Multiple Matches” and reply back to the user with the message “Just to confirm, did you mean predictions[0]?” (which is translated into “Just to confirm, did you mean Boston, MA, USA?”).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*BWFbLHx5QfrshWx94AAiDQ.png" /><figcaption>We should never assume!</figcaption></figure><p>While user inputs are never predictable we can try and think about what at this stage of the conversation the user <strong>is most likely </strong>to say. “Multiple Matches” needs to handle (at least) a positive answer, a follow up from the customer, a negative answer and the unresolved intent. A positive answer will call a backend service to fulfill the user request. In my opinion, other inputs like “New Boston Texas” or “No, New Boston Texas” should match the “findTrains” intent again. In the example below the second invocation of the Places Autocomplete service has returned a single match.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*Lyn2GOGwf3OzUu5M-8PYyw.png" /><figcaption>Help the conversation unfold naturally</figcaption></figure><p>On the other hand if the user response is negative with no further information provided I think it’s a good idea to be cooperative and display the other predictions without transitioning to a different page. Ultimately the goal is to help disambiguate and move the conversation forward to fulfill the user intent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*UAwWWKBBqhXVFpFV6URPEw.png" /></figure><h3>Conclusions</h3><p>If you’ve come this far (unless you skipped the previous paragraphs!) I should really thank you for sticking with me till the end of this quite long blog post. I hope you enjoyed reading as much as I enjoyed writing and if you have any questions/feedback please comment or reach out. If you’re keen to check out the webhook implementation, <a href="https://github.com/alessiasacchi/google-cloud-functions/tree/main/cx-google-maps-webhook">code</a> is available on my GitHub. Look forward to hearing from you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ebd5efcdf9e5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/using-google-maps-places-api-to-validate-locations-during-a-conversation-with-a-virtual-agent-ebd5efcdf9e5">Using Google Maps Places API to “validate” locations in a conversation with a virtual agent</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Who said you can’t code on a Chromebook? Local development with Cloud Functions.]]></title>
            <link>https://medium.com/google-cloud/who-said-you-cant-code-on-a-chromebook-local-development-with-cloud-functions-4e68dca1240b?source=rss-55e4556cd81b------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e68dca1240b</guid>
            <category><![CDATA[local-development]]></category>
            <category><![CDATA[google-cloud-functions]]></category>
            <category><![CDATA[chromebook]]></category>
            <category><![CDATA[gcp-app-dev]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <dc:creator><![CDATA[Alessia Sacchi]]></dc:creator>
            <pubDate>Wed, 01 Dec 2021 14:40:12 GMT</pubDate>
            <atom:updated>2021-12-01T18:36:54.874Z</atom:updated>
            <content:encoded><![CDATA[<p>When I joined Google in January I was given the option to choose my laptop among several options across the main four platforms: Chrome, gLinux, macOS and gWindows. I liked the idea of starting my laptop in 5 seconds (my Samsung phone takes longer to turn on) but I can’t deny I was sceptical about coding. Well, the truth is it’s easy to dismiss Chromebooks and while they don’t use an OS on the same scale as Windows 10 or macOS, the platform has been maturing over time into something lightweight but still well featured.</p><p>This blog post describes the process of setting up Linux on a Chromebook and writing a simple HTTP Cloud Function using the Node.js runtime, Visual Studio Code and Google Cloud Functions Framework for Node.js. Let’s get started!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*tNaWXyK2bEQmoBMtprr8jw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@oskaryil?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Oskar Yildiz</a> on <a href="https://unsplash.com/s/photos/coding?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Set up Linux, Node and Visual Studio on your Chromebook</h3><p>First things first, if you want to develop software on your Chromebook you will need to set up Linux. You can install Linux command line tools, code editors, and IDEs (integrated development environments) on your Chromebook. These can be used to write code, create apps, and more. <a href="https://sites.google.com/a/chromium.org/dev/chromium-os/chrome-os-systems-supporting-linux">If your device has Linux</a> it will be off by default. You can turn it on any time from Settings. On your Chromebook, at the bottom right, select the time. Then select Settings &gt; <strong>Advanced </strong>&gt;<strong> Developers. </strong>Next to “Linux development environment,” select Turn On and follow the on-screen instructions. The setup of a Debian 10 (Buster) environment can take 10 minutes or more. You can run Linux commands, install more tools using the APT package manager, and customize your shell. A good first thing to do is update the <a href="https://wiki.debian.org/Apt">APT⁠</a> repository index and install. APT is a command-line package manager for Debian, and keeping it up to date will ensure you’re always installing the latest versions of tools in its repository:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*qwRHc1pPvZRbLZrgujLSRg.png" /><figcaption>Running `apt-get update`</figcaption></figure><p>Hint! A simple way to access files in the Linux container is to make a copy. To do so, open the Files app, drag whatever directory or file you want to access, and drop it in “Linux files”.</p><p>Now that Linux is set up, to install Node.js we need to make sure that we’re running the installer commands as root (at time of writing the current version of Node is 17.1.0).</p><pre>sudo /bin/bash<br>curl -fsSL https://deb.nodesource.com/setup_17.x | bash -<br>sudo apt-get install -y nodejs</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BnlB093QuAiZXK3eXjswgg.png" /><figcaption>Installing the NodeSource Node.js 17.x repo in the terminal</figcaption></figure><p>If you run into errors due to any existing conflicting versions of Node clean up your environment by running:</p><pre>sudo apt remove — purge nodejs node npm<br>sudo apt clean<br>sudo apt autoclean<br>sudo apt install -f<br>sudo apt autoremove</pre><p>Now that a Crostini Linux container is set up and Node is installed, we are going to move on to Visual Studio Code. What is it? It is a lightweight but powerful source code editor which runs on desktops and is available for Windows, macOS and Linux. It comes with built-in support for JavaScript, TypeScript and Node.js and has a rich ecosystem of extensions for other languages (such as C++, C#, Java, Python, PHP, Go) and runtimes (such as .NET and Unity).</p><p>While you can always install apps and tools in the terminal via sudo apt install, Linux on Chrome OS supports double-click to install for .deb files (Debian software package) in the Files app, allowing you to download and install apps like you’re used to. Visual Studio Code, for instance, offers a <a href="https://code.visualstudio.com/download">.deb⁠</a>package, that you can try this with. Once downloaded open the Files app, right-click and select “Install with Linux (Beta)”. You’ll see a prompt with information about the app you’re looking to install, along with the option to install the app. From here on out you’ll be able to launch Visual Studio Code from the app drawer like any other application on your Chromebook once the Linux installer has finished. You can also launch it from the terminal simply by typing <em>code</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eRaxjKrgmQc5I6ntnlOa6w.png" /><figcaption>Visual Studio Code on Chrome OS</figcaption></figure><h3>Create and test a HTTP Cloud Function locally</h3><p><a href="https://cloud.google.com/functions">Google Cloud Functions</a> is an event-driven serverless compute platform. Cloud Functions allows you to write your code without worrying about provisioning resources or scaling to handle changing requirements. Because testing code on Cloud Functions itself involves waiting for deployed code and log entries to become available, running and testing your function on your development machine can make the testing process (and, in turn, the development process) significantly faster.</p><p>Before we create and test the Cloud Function in Visual Studio there’s one last step we need to do as part of the local dev environment setup: install the <a href="https://codelabs.developers.google.com/codelabs/local-development-with-cloud-functions#2">Functions Framework for Node.js</a>. The Google Cloud Functions team has created an open source FaaS (Function as a Service) framework for writing portable Node.js functions that run in many different environments, including Google Cloud Functions, your local development machine, Cloud Run and Cloud Run on GKE and Knative-based environments.</p><p>So, let’s create a new Node.js app by running npm initin the terminal. While accepting defaults, make sure to use index.js as the entry point for your app.</p><pre>mkdir ~/helloworld<br>cd ~/helloworld<br>npm init </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c98Cy0YqiEcDfrL1Yj3qYA.png" /><figcaption>Create a simple HTTP Cloud Function using npm init</figcaption></figure><p>Then install the Functions Framework for Node.js (npm install @google-cloud/functions-framework). Open your <em>package.json</em>. Verify that you see the functions framework listed as a dependency as shown in the example below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*ya0xK0EJ8a9zWDRdtGwJAQ.png" /><figcaption>Install the Functions Framework</figcaption></figure><p>We are now ready to edit the Cloud Function in Visual Studio Code. Click the Explorer icon in the IDE and open the folder you have just created. Now create an index.js file in the helloworld directory and add some hello world code :-). To test the the function using the integrated terminal within Visual Studio open a terminal window and run the following command:</p><pre>npx functions-framework --target=helloWorld</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qUSI6Eaee1hnsfyEnJtCXA.png" /></figure><p>This command starts a local server that is ready to call the helloWorld function when the server receives an HTTP request. To test the function create a second terminal window and run the following command to send a name payload to the local server serving the helloWorld function.</p><pre>curl -X POST http://localhost:8080 -H &quot;Content-Type:application/json&quot;  -d &#39;{&quot;name&quot;:&quot;Alessia&quot;}&#39;</pre><p>Now that you’ve created and tested the Cloud Function on your local machine, you are ready to deploy it to Google Cloud. Before doing that though, we need to make sure all the <em>node_modules</em> are going to be excluded from the deployment when we deploy to Google Cloud. For this specific purpose we need to add a file called .gcloudignore in the top-level directory. This .gcloudignore prevents the upload of the node_modules/ directory and any files ending in ~:</p><pre>/node_modules/<br>*~</pre><h3>Deploy a Cloud Function from a local machine to Google Cloud</h3><p>Now that we have packaged the application for Cloud Functions, the next step is to deploy it to Google Cloud. To do this we need to <a href="https://cloud.google.com/sdk/docs/quickstart#installing_the_latest_version">install Cloud SDK</a> locally and perform several common Cloud SDK setup tasks using the <a href="https://cloud.google.com/sdk/gcloud/reference/init">gcloud init</a> command. These include authorizing the Cloud SDK tools to access Google Cloud using your user account credentials and setting up the default configuration (make sure to set the project ID not the project number).</p><p>Once your Google Cloud SDK is configured and ready to use in any terminal window run the following command:</p><pre>gcloud functions deploy helloWorld --trigger-http --runtime nodejs12 --allow-unauthenticated</pre><p>When deployment is completed, you will see the following in the output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4qFeh5h5xx6ZFIEnMPB4bA.png" /></figure><p>We’re done! Thanks for reading this blog post where we’ve explored how to streamline local development with Cloud Functions for Node.js using Visual Studio Code on a Chromebook.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e68dca1240b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/who-said-you-cant-code-on-a-chromebook-local-development-with-cloud-functions-4e68dca1240b">Who said you can’t code on a Chromebook? Local development with Cloud Functions.</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Dialogflow CX composite entities to work around system entities limitations]]></title>
            <link>https://medium.com/google-cloud/using-dialogflow-cx-composite-entities-to-work-around-system-entities-limitations-c6385df12f2b?source=rss-55e4556cd81b------2</link>
            <guid isPermaLink="false">https://medium.com/p/c6385df12f2b</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[conversational-interfaces]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[dialogflow]]></category>
            <dc:creator><![CDATA[Alessia Sacchi]]></dc:creator>
            <pubDate>Mon, 22 Nov 2021 19:59:57 GMT</pubDate>
            <atom:updated>2021-11-23T13:07:12.739Z</atom:updated>
            <content:encoded><![CDATA[<p>Dialogflow CX provides many <em>system entities</em> to extract common types from end-user expressions. For most use cases, the values provided by system entities work well however support differs for languages and regions. Some system entity types are not yet available in non-US and non-global regions while others that are currently available have some limitations for specific languages like Italian. This post describes how system entities can be combined into custom composite entities to overcome some of those limitations.</p><p>Let’s dive in!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_wVRPYG7LCv91gY3wFQxGg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@ashkfor121?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Ashkan Forouzani</a> on <a href="https://unsplash.com/s/photos/puzzle-pieces?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Some time ago one of my clients discovered a quirk of <strong>@sys.date-time</strong> when used with the Italian language. I will provide some examples below and if you don’t speak Italian this is a good opportunity to start learning ;-)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*1e-16uHLGY9AeTbUZ_eDvg.png" /></figure><p>The table shows that user input like <em>“in a week’s time at 9 AM”</em> or <em>“on 22nd August at 9 AM”</em> are not parsed correctly. In the first scenario the date is correct but the time is wrong. In the second one the date is missing. In the third and the forth scenarios the system entity resolves the date as a date period and it doesn’t match the time.</p><p>The issues were also reproduced outside of europe-west1 in the Global region and when the NLU team tested all the cases they found the scores of the output were not ideal. To be more specific:</p><ol><li><em>&quot;tra una settimana alle 9&quot; -</em> The output has both datetime point of 9am/pm today (correct), as well as a datetime annotation “in a week” (wrong) annotation, but the latter has higher score.</li><li><em>“22 agosto alle ore 9” -</em> Again the output has both datetime point of Aug 22nd 9am (correct), as well as a period (wrong) annotation, but the latter has higher score.</li></ol><p>I found that a possible way to work around those issues is a custom composite entity that uses both <strong>@sys.date</strong> and <strong>@sys.time</strong>.</p><p>A <a href="https://cloud.google.com/dialogflow/cx/docs/concept/entity-options#comp"><em>composite entity</em></a> is a special kind of list entity. Entity entries for list entities typically contain simple words or phrases, but they may also contain other entity types. When an entity type is referenced in another entity type, the reference is called an <em>alias</em>. When a list entity contains aliases to other entity types, it is called a composite entity.</p><p>For this specific purpose of parsing a date and a time from the user input we need to create a custom composite entity that has the following entity entries and doesn’t have synonyms:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*ObUDd32BPkgWsTILRG907w.png" /><figcaption>The composite entity entries</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*JGwMEL7DnvvI5Jpv3HlRoQ.png" /><figcaption>Remember to check this box</figcaption></figure><p>In a composite entity the reference to another entity type (like @sys.date and @sys.time) is called an <em>alias. </em>When creating an alias, you supply the name of the referenced entity type and a property name of your choosing. You can also use multiple entity aliases in an entity entry. That’s exactly what we are doing here. Our custom entity type contains aliases to the @sys.date system entity type and the @sys.time system entity type in one entry. The format for entering an alias is:</p><pre>@entity-name:property-name</pre><p>When a composite entity is matched at runtime, the extracted value is returned as a JSON object, with alias property names used as JSON property names. If an end-user input contains both a date and a time like “<em>22 agosto alle 9</em>” the extracted value is returned as a JSON object like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*AxMxqgr0oGMBhTd8GzsKtg.png" /><figcaption>The date-time parameter matched at runtime (date and time)</figcaption></figure><p>I want to bring your attention to the second entry of the composite entity.</p><pre><a href="http://twitter.com/sys">@</a>sys.time:time del <a href="http://twitter.com/sys">@</a>sys.date:date</pre><p>“<strong><em>del</em></strong>” (<em>of</em>) is the preposition that precedes the date and it allows the entity to match both time and date when they’re passed in this order. Words or phrases used in composite entities are very powerful. For example, consider a flight booking agent and the following end-user input “<em>I need to book a flight from Melbourne to Sydney</em>”. Melbourne and Sydney are locations hence the system entity @sys.location can extract them however how do we disambiguate between departure city and destination? That’s why we need to include the prepositions “from” and “to” in a composite entity entry.</p><pre>from <a href="http://twitter.com/sys">@</a>sys.location:departure to <a href="http://twitter.com/sys">@</a>sys.location:destination</pre><p>Back to date and time you would have noticed that I also added @sys.date:date and @sys.time:time as two separate entries. That allows the composite entity to match an end-user input that contains a date or a time part only. If the input contains a <em>“22 agosto”</em> part, the date entity type is matched and the extracted value is returned as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*G96oVci8mbtgHljThAJDig.png" /><figcaption>The date-time parameter matched at runtime (date only)</figcaption></figure><p>Why? According to the Cooperative Principle, efficient communication relies on the assumption that there’s an undercurrent of cooperation between conversational participants. Research has shown that people respond to technology as they would to another human. There is a chance our end-user provides only the date or the time and in a human-to-human conversation that piece of information would certainly be collected. A human assistant will follow up asking <em>“what time?”</em> if just the date is provided or <em>“what day?”</em> if just the time is provided. That’s exactly how I expect a virtual agent to interact with a user.</p><p>Hooray, we are all set! Aren’t we? Not jet. :-) In Italian <em>“22 Agosto alle ore 9”</em> means <em>“22nd August at 9 AM”</em> because we have adopted the 24-hour clock. Having said that if at 4 PM I message a friend to let her know we are meeting up at 6 PM I will write something like “vediamoci alle 6” instead of “vediamoci alle 18”. She knows we are catching up in two hours time and not tomorrow morning at 6 AM because she has context. The context here is we want to meet for dinner and not for breakfast ;-)</p><p>The online documentation of Dialogflow CX states “If there is ambiguity in end-user input due to missing date/time elements, the nearest matching future date/time is returned.”. Using the system entities @sys.date and @sys.time in a composite entity instead of the system entity @sys.date-time has the downside that we need to write some custom business logic to disambiguate whether the user actually means 9 AM or 9 PM depending on the context. Alternatively the matched time is going to depend on the current time, since Dialogflow picks the closest time in the future that matches the given input.</p><p>To summarise, Dialogflow CX composite entities provide powerful capabilities to match data. In fact many system entities are composite entities. They can also be used to overcome some of the current limitations of the system entities to extract common types from end-user expressions as system entity support differs for languages and regions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c6385df12f2b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/using-dialogflow-cx-composite-entities-to-work-around-system-entities-limitations-c6385df12f2b">Using Dialogflow CX composite entities to work around system entities limitations</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>