<?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 Kody O&#39;Connell on Medium]]></title>
        <description><![CDATA[Stories by Kody O&#39;Connell on Medium]]></description>
        <link>https://medium.com/@KodyOConnell?source=rss-97cf96028ca8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*0cfJyfK9HUB453__.jpg</url>
            <title>Stories by Kody O&amp;#39;Connell on Medium</title>
            <link>https://medium.com/@KodyOConnell?source=rss-97cf96028ca8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 01:48:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@KodyOConnell/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[What Apple Can Teach You About Releasing Software]]></title>
            <link>https://medium.com/@KodyOConnell/what-apple-can-teach-you-about-releasing-software-c52b3f848c91?source=rss-97cf96028ca8------2</link>
            <guid isPermaLink="false">https://medium.com/p/c52b3f848c91</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Kody O'Connell]]></dc:creator>
            <pubDate>Thu, 09 Jan 2020 20:35:49 GMT</pubDate>
            <atom:updated>2020-01-10T00:02:22.855Z</atom:updated>
            <content:encoded><![CDATA[<p>Depending on your recent experience with Apple, as a consumer using Apple products or as a developer working with iOS, you may have noticed some bugs in the latest software. Of course, you wouldn’t be alone. Apple has for years been plagued by buggy software launches.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9KKF4XYxjRNyf7uu" /></figure><p>To be fair, their installed user base has skyrocketed in the past decade. Delivering new features with quality control at global scale is a difficult problem that even Apple has trouble with.</p><p>In a recent <a href="https://www.bloomberg.com/news/articles/2019-11-21/apple-ios-14-features-changes-testing-after-ios-13-bugs">article</a> Bloomberg reports Apple’s struggle to launch their latest feature-packed operating system, iOS 13.</p><blockquote><em>“Test software got so crammed with changes at different stages of development that the devices often became difficult to use. Because of this, some ‘testers would go days without a livable build, so they wouldn’t really have a handle on what’s working and not working,’ the person said. This defeated the main goal of the testing process as Apple engineers struggled to check how the operating system was reacting to many of the new features, leading to some of iOS 13’s problems.”</em></blockquote><h3>Enter: Feature Management</h3><p>As software complexity grows, it becomes harder to ensure components interact and function correctly. Predicting downstream effects of a new feature when there are many teams releasing their own features simultaneously is basically impossible.</p><p>To finally address this problem, Apple is turning to a relatively new, but industry tested and verified, practice: “<strong>Feature Management</strong>”. Feature Management is a code release practice adopted by progressive companies looking to improve their continuous delivery methods and their reputation with customers who demand more features and fewer bugs. Feature Management enables you to release new features into production but hide them behind a “feature flag”. In code you ask “is this feature enabled for this userId?” and only show the feature to userIds who are allowed to see it. You can then define remotely (not in your code) which users are allowed to see the new feature and test the feature <strong>in production</strong>without the risk of exposing it to all your users immediately.</p><p>From the Bloomberg article:</p><blockquote><em>“Testers will have the option to selectively enable features, via a new internal process and settings menu dubbed Flags, allowing them to isolate the impact of each individual addition on the system.”</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/0*PHHgszUMzUPIrAjy" /></figure><p>This is great news! Now testers (and developers) will be able to toggle specific features allowing them to isolate a particular bug much easier. Also, Apple will have greater control over which features are shown to which users allowing them to “rollback” buggy features and quickly improve the user experience for millions of people.</p><blockquote><em>“The testing shift will apply to all of Apple’s operating systems, including iPadOS, watchOS, macOS and tvOS. The latest Mac computer operating system, macOS Catalina, has also manifested bugs such as incompatibility with many apps and missing messages in Mail.“</em></blockquote><h3>Feature Management Options</h3><p>Before considering feature management for your software delivery practice, it’s important to know your options.</p><p><strong>DIY (Do it Yourself)</strong></p><ul><li>Typically the lowest effort and quickest implementation</li><li>Example: define flags and users who can access them in a .env</li><li>Not good for scale, remote access, or specificity</li><li>Free (not counting engineers building it)</li></ul><p><strong>Open Source</strong></p><ul><li>Medium to high effort customizing to your stack</li><li>Free (not counting engineers implementing and managing it)</li></ul><p><strong>Feature Management aaS (as a service)</strong></p><ul><li>Best for scale and enterprise</li><li>Allows non-technical teams to engage with feature deploys via UIs</li><li>Fully managed</li><li>Some are <strong>free</strong>!</li></ul><h3>Beyond Feature Management</h3><p>After an organization implements feature management to release most of its new features, they may realize they want even more control over their feature launches. Instead of simply toggling a feature <strong>on </strong>or <strong>off</strong> for a user, they may want to tweak the parameters of a feature and <em>test</em> which version of a feature has the most desired effect. This incorporation of variables and tracking results with feature flags enables <strong>experimentation</strong>.</p><h3>Conclusion</h3><p>Like most new technologies, Apple waited to see the industry validate feature management before incorporating it (like it does with consumer tech). However, at it’s scale, Apple can no longer operate without feature management. There are clear benefits when using feature flags at any scale, as well as implementation options to suit your specific needs. So learn from Apple, and don’t wait until it’s too late to implement feature management.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/0*XYeFotl_4KbUfM1b" /></figure><p>p.s. If you’re looking for a good managed free solution to get started with, check out <a href="https://www.optimizely.com/rollouts/?utm_campaign=apple_medium">Optimizely</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c52b3f848c91" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Xero OAuth 2 API — What’s new + Node example]]></title>
            <link>https://devblog.xero.com/xero-oauth-2-api-whats-new-node-example-94715fc8ff19?source=rss-97cf96028ca8------2</link>
            <guid isPermaLink="false">https://medium.com/p/94715fc8ff19</guid>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[xero]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[oauth2]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Kody O'Connell]]></dc:creator>
            <pubDate>Thu, 05 Sep 2019 17:47:00 GMT</pubDate>
            <atom:updated>2019-09-19T18:35:40.000Z</atom:updated>
            <content:encoded><![CDATA[<h3>Xero OAuth 2.0 API — What’s new + Node example</h3><p>Xero is excited to launch our new OAuth 2.0 API with support for OpenID Connect (single sign-on) and a simplified OAuth configuration. In this post I’ll go over the main changes to be aware of if you’ve built on our API before, and how to see them for yourself in a simple node express app.</p><p>The app uses<a href="https://www.npmjs.com/package/openid-client"> openid-client</a> to complete our new API’s OAuth 2.0 flow and a simple http client to access invoice and org data (soon we will release new SDK’s that provide OAuth 2.0 methods). Please check out<a href="https://github.com/XeroAPI/node-oauth2-example"> the app</a> and specifically the code in<a href="https://github.com/XeroAPI/node-oauth2-example/blob/master/index.js"> index.js</a> and follow along for the best reading experience!</p><h3>What’s New in OAuth 2.0</h3><p>Xero’s new API is built to the industry standard<a href="https://oauth.net/2/"> spec</a> for OAuth 2.0, so if you’ve used it before it will be very familiar to you (if so feel free to skip to Access Token Changes).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*Et1UIbiEcCwNK98E" /></figure><p>Above is an example config.json showing all you need to have to configure your API access. You can set up a new OAuth 2.0 app in the<a href="https://developer.xero.com/myapps/"> My Apps</a> section at developer.xero.com. Once there, set your app name, redirect URL and generate a new client secret (this is only viewable once so store it in a safe place!).</p><h3>Access Token Changes</h3><p>In Xero’s original API, access tokens were tied to the organisation selected by the user in the OAuth flow. Sending the access token in your API call to get info from the Organisation endpoint would result in info for only that organisation being returned. In our OAuth 2.0 API we’ve decoupled that relationship and made the access token much more extensible by relating it to the <em>user</em> who authorized access. Now you can access a connections endpoint (https://api.xero.com/connections) to retrieve a list of ‘tenant ids’ where tenant is a generic term for either a Xero Organisation or a Xero Practice. You’ll see in the example app below how to implement the OAuth flow and immediately request that list of ids and then use one to fetch data by passing it in a header called ‘xero-tenant-id’.</p><h3>Run the Example</h3><p>Try the below steps to get started with the node sample app (no SDK) and start using our OAuth 2.0 API.</p><ol><li>Clone the<a href="https://github.com/XeroAPI/node-oauth2-example"> repo</a></li><li>Setup your OAuth 2.0 app in the Xero<a href="https://developer.xero.com/myapps/"> dev portal</a> (click try OAuth 2.0 at top right, and be sure to set your redirect URI to<a href="http://localhost:5000/callback"> http://localhost:5000/callback</a>)</li><li>Copy API credentials into config.json (use a .env in production)</li><li>npm install, npm start</li><li>From<a href="http://localhost:5000/"> app</a>, click through OAuth flow and view printed results from API in console</li></ol><h3>New OAuth Flow</h3><p>As you click through the sample app you’ll start by clicking the connect button from the root page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/0*FDspdESSjXAjQhiy" /><figcaption>root page, click link to start OAuth flow</figcaption></figure><p>You’ll be navigated to Xero’s identity server requesting access to your Xero user details on behalf of our example app ‘Banana’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/0*PLrhAOKqhMR0zTfr" /><figcaption>user details authorization screen</figcaption></figure><p>Allowing access will tell the API to return an idToken which contains the user information like name and email, and a universally unique identifier (<a href="https://en.wikipedia.org/wiki/Universally_unique_identifier">UUID</a>) that can be used by your app for<a href="https://openid.net/connect/"> OpenID Connect</a> based single sign-on if you wish.</p><p>Next the API will process the scopes our app has passed along and redirect to a second screen to ask the user to authorize access to the specific resources defined by the scopes.</p><pre>“SCOPES”: “openid profile email accounting.transactions accounting.settings offline_access”</pre><p>The above scopes are set in the config of the example app and produce the below authorization screen. Feel free to experiment with<a href="https://developer.xero.com/documentation/oauth2/scopes"> our scopes</a> in the sample app to see how best to limit your app’s access to just the data you need (great security practice!).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/387/0*ydQmiLuVwg3gK4H0" /><figcaption>the scopes ‘accounting.transactions accounting.settings’ translate to business transactions and organisation settings request above</figcaption></figure><p>Clicking connect will tell the API to set new access rights on your user based access token to access the Xero tenant you select in the dropdown. The API will redirect the user to the defined redirect URI. Our sample app will now print out the OAuth data returned in the console and redirect to our /home page which has links to test getting organisation and invoice data and refreshing of the access token (all results will print in the console).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/0*YmKUDg1cVPGGtWDS" /><figcaption>our app’s /home page after a successful OAuth flow</figcaption></figure><h3>Connections</h3><p>Finally, the app will request the list of authorized tenants from<a href="https://api.xero.com/connections"> https://api.xero.com/connections</a> and save the first tenantId to send in the header ‘xero-tenant-id’ for our API calls to access that tenant data. In this case the tenant is a normal Xero organisation, so the tenantId is the same as the organisationId.</p><h3>Conclusion</h3><p>Above you saw that Xero’s new OAuth 2.0 API is built to the industry standard spec and provides a great new way to authenticate users in your app with<a href="https://developer.xero.com/documentation/oauth2/sign-in"> Xero single sign-on</a> via OpenID Connect. You also saw how to quickly get started with the node example for using the new OAuth 2.0 API without any SDK. We hope this knowledge empowers you to try out<a href="https://github.com/XeroAPI/node-oauth2-example"> the sample app</a> or make your own to test the new API. Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94715fc8ff19" width="1" height="1" alt=""><hr><p><a href="https://devblog.xero.com/xero-oauth-2-api-whats-new-node-example-94715fc8ff19">Xero OAuth 2 API — What’s new + Node example</a> was originally published in <a href="https://devblog.xero.com/">Xero Developer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Security Works in the Xero API]]></title>
            <link>https://medium.com/@KodyOConnell/how-security-works-in-the-xero-api-a0646765fd3?source=rss-97cf96028ca8------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0646765fd3</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[xero]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[oauth]]></category>
            <dc:creator><![CDATA[Kody O'Connell]]></dc:creator>
            <pubDate>Thu, 07 Jun 2018 18:13:56 GMT</pubDate>
            <atom:updated>2019-06-26T23:10:10.425Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Over a million small businesses, and their advisors are looking for the best cloud apps that integrate with Xero. </em><a href="https://developer.xero.com/partner/app-partner?utm_source=Medium&amp;utm_medium=Blog&amp;utm_campaign=content_marketing"><em>Partner with us</em></a><em>, and we’ll make sure they find yours.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/310/0*r5Z8h5V4JmddeCnC." /></figure><p>At Xero, we are trusted with our small business customers’ most valuable and sensitive data. Because a person’s small business is often their livelihood, and/or their devotion in life, we take our responsibility in protecting this data very seriously.</p><p>Apart from the <a href="https://www.xero.com/us/why-xero/benefits/security/">security</a> of Xero’s <a href="https://www.xero.com/us/about/security/">core products</a>, Xero API’s provide their own layers of security while still allowing 3rd parties to access data only with explicit permission from a Xero user with rights to provide that access.</p><p>This post is meant to explain the methods that Xero’s API’s employ to ensure a high standard of security that allows our partners to access powerful data without needing to worry about breaches that would lead to massive data theft through your API connection. Rest assured that Xero has you covered.</p><h3>How Do I Securely Connect to the Xero API(s)?</h3><p>There is only one way to connect to the Xero API’s at any significant scale (# of connections) and with long life access tokens — the Xero Partner API.</p><p>You can see details of connecting on the Partner API <a href="https://developer.xero.com/documentation/auth-and-limits/partner-applications">here</a>, but here is the short summary of the initial process required:</p><ol><li>Access granted by a Xero Developer Evangelist only after reviewing your Public API integration</li><li>Implement the logic to connect your app to Xero via <a href="https://oauth.net/core/1.0a/">OAuth 1.0a</a> with a <a href="https://developer.xero.com/documentation/libraries/overview">Xero SDK</a> or other third party <a href="https://www.google.com/search?q=OAuth+1.0a+SDK">OAuth SDK</a> (homemade OAuth implementations are not recommended)</li><li>Test the connecting flow being sure to handle any <a href="https://developer.xero.com/documentation/auth-and-limits/oauth-issues">error responses</a> that can occur during the OAuth flow</li><li>Deploy</li></ol><h3>What measures does Xero take to ensure security in connections to its API’s?</h3><p>Apart from complying with industry best practices and conforming to the new <a href="https://en.wikipedia.org/wiki/Transport_Layer_Security">TLS</a> standard (see our <a href="https://devblog.xero.com/tls-1-2-and-the-xero-api-3f8e8b66fc0e">post on upgrading to TLS 1.2</a>) for baseline data transfer across the internet, Xero goes above and beyond with other built in security features in our API’s.</p><h4>All API communication is signed and encrypted</h4><p>The Xero Partner API will only accept requests signed using RSA-SHA1. When registering your Partner App you will need to upload a self generated public certificate. To do this you need to <a href="https://developer.xero.com/documentation/api-guides/create-publicprivate-key/">generate a public/private key pair.</a></p><p><em>It’s best to use a </em><a href="https://developer.xero.com/documentation/libraries/overview"><em>Xero SDK </em></a><em>or other plugin to handle OAuth and especially signing in OAuth. See </em><a href="https://oauth1.wp-api.org/docs/basics/Signing.html"><em>this introduction</em></a><em> to how signing requests in OAuth 1.0a works.</em></p><p>Once you upload your public key to Xero, Xero will store it securely and use it to validate any requests that come from your Partner App. This works by using your public key to decrypt the request you send and is mathematically proven to be secure. Only requests that are signed with your legitimate private key will be accepted. Any attempt to spoof this key will be detected and the Xero API will never deliver any information back to a request that does not come with the correct signature encoded with your private key.</p><h4>Access tokens expire after 30 minutes</h4><p>For each Xero organisation that your app connects to, you will need to keep track of individual access tokens that provide access to that organisation’s data. These access tokens are valid for only 30 minutes at a time. When your access token expires you use your expired access token (along with the session handle and the access token secret associated with the access token) to exchange the expired access token, for a new access token. The new access token is also only valid for 30 minutes.</p><p>This means that you should let your access tokens expire and only refresh them when you need to make a call to the Xero API. With this extra layer of security, if you separate your access token secret from your private key and other credentials, it will be that much harder for an infiltrator to access Xero data through your connection, as they’d need to get a new access token before even attempting to make an API call. This 30 minute expiry further enhances Xero security as the ability to perform a brute force style attack within this 30 minute window greatly reduces risk.</p><h4>What would an infiltrator have to do to compromise this connection and access Xero data through my system?</h4><p>Ideally you follow <a href="https://support.google.com/cloud/answer/6310037?hl=en">best practices</a> for separating your API keys from your production code and implement other <a href="https://medium.freecodecamp.org/how-to-securely-store-api-keys-4ff3ea19ebda">methods to securely store</a> them. This should prevent even someone who manages to break into your system via a security hole or phishing attack that gives them access to your code base, from using these API keys to access data from Xero. Even so, the added layers of security you place around the credentials to refresh access tokens and encrypt and sign requests with your private key should prevent them from being able to make a single API call. If you follow best practices around securing the way you connect to the Xero API, you should be completely safe from an infiltrator using your connection to the Xero API.</p><h3>FAQ</h3><h4>Why aren’t you using SHA2? I heard that SHA1 is no longer secure.</h4><p>In February of 2017 Google announced the <a href="https://security.googleblog.com/2017/02/announcing-first-sha1-collision.html">first SHA1 security breach</a>. Organisations that create the SHA (Secure Hashing Algorithm) standards had been advocating for users to switch to SHA2 for some time, expecting that eventually increased computational power would enable the cracking of SHA1. This was the first demonstration of that prediction.</p><p>Xero is actively migrating our API’s to use the newer more secure SHA2 standards (we already use SHA2 for the SSL connection) and will proactively communicate and help our partners to migrate to our new API when it is ready. In the meantime our partners should not be alarmed by this news. As described by Google in their announcement, their demonstrated cracking of SHA1 was “one of the largest computations ever completed” and required “6,500 years of CPU computation to complete the attack first phase, and 110 years of GPU computation to complete the second phase”. At this point in time only certain nation states could replicate this type of attack, and combined with the unlikely cracking of the other Xero API security measures described above, this would only conceivably allow 30 minutes of access to a single Xero customer’s data.</p><h4>Can you block my access to certain sensitive data?</h4><p>Xero provides privileged access to its <a href="https://developer.xero.com/documentation/api/api-overview">different API’s</a> (use the drop down to view the API’s) on a partner-by-partner basis. You will only have access to the Accounting, Assets, Files, and Signup API’s as a default. The Payroll API’s can be accessed only with explicit permission granted by the Xero customer as described in the permissions section of the respective Payroll API docs. Xero is not able to block your access to certain endpoints within the Accounting API. If you are concerned about the ability of an infiltrator accessing your system to use it to get data from the Xero API please see the section above — “What would an infiltrator have to do to compromise this connection?”. If you write your code to avoid accessing the endpoints you don’t want to touch, and refrain from storing any sensitive data that you don’t wish to be liable for, then no attacker should be able to use your connection to the Xero API to go and fetch that information.</p><h3>Conclusion</h3><p>Now that you’re armed with the knowledge of how security works in the Xero API, you can go forward with confidence that building powerful integrations with secure RESTful API’s can provide not only best in class features for your customers, but also best in class security.</p><p>Cheers and thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0646765fd3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Alexa Skills and the Xero API]]></title>
            <link>https://devblog.xero.com/alexa-skills-and-the-xero-api-d900469b06f3?source=rss-97cf96028ca8------2</link>
            <guid isPermaLink="false">https://medium.com/p/d900469b06f3</guid>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[alexa]]></category>
            <category><![CDATA[xero]]></category>
            <category><![CDATA[accounting]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <dc:creator><![CDATA[Kody O'Connell]]></dc:creator>
            <pubDate>Thu, 30 Nov 2017 18:05:15 GMT</pubDate>
            <atom:updated>2019-06-26T23:10:43.172Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Over a million small businesses, and their advisors are looking for the best cloud apps that integrate with Xero. </em><a href="https://developer.xero.com/partner/app-partner?utm_source=Medium&amp;utm_medium=Blog&amp;utm_campaign=content_marketing"><em>Partner with us</em></a><em>, and we’ll make sure they find yours.</em></p><h3>Intro</h3><p>Have you ever wondered how great it would be to have a personal assistant help you out with your day to day tasks? With modern A.I. assistants like Amazon’s Alexa, you can create custom “skills” that allow them to help you out with whatever you’d like, including running your small business.</p><p>We made an Alexa Skill that showcases the power of Xero’s accounting API and enables you to ask Alexa for a daily summary of your business, get contact information for suppliers and customers, and even pay your bills, all with just your voice.</p><p>We also decided to use modern serverless technologies to show how easily you can build a service that will remain performant and cost effective, even if it scales quickly.</p><p>In this post you’ll get an intro to the following as we explain how we made this sample project:</p><ul><li>Alexa Skills Kit concepts</li><li>Deploying node.js projects to serverless infrastructure</li><li>Linking a custom Alexa Skill to a Xero account using OAuth</li></ul><p>Check out our <a href="https://github.com/XeroAPI/xdhax-alexa-sample">github</a> for full instructions on replicating this project.</p><h3>What We Used</h3><h4>Core Technologies</h4><p>We used these technologies as the foundation of this project.</p><ul><li><a href="https://aws.amazon.com/">Amazon Web Services</a></li><li><a href="https://nodejs.org/">Node.js</a></li><li><a href="https://developer.amazon.com/alexa-skills-kit">Amazon Alexa Skills Kit</a></li><li><a href="https://developer.xero.com/documentation/api/api-overview">Xero Accounting API</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qYQNdiExw7HnhpGs." /></figure><h4>Serverless Technologies</h4><p>We used these Amazon Web Services technologies to create an entirely <a href="https://en.wikipedia.org/wiki/Serverless_computing">serverless infrastructure</a> stack for this project.</p><ul><li><a href="http://docs.aws.amazon.com/lambda/latest/dg/welcome.html">Lambda</a></li><li><a href="http://docs.aws.amazon.com/apigateway/latest/developerguide/welcome.html">API Gateway</a></li><li><a href="https://aws.amazon.com/dynamodb/">Dynamo DB</a></li><li><a href="https://aws.amazon.com/s3/">S3</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/0*c9TbdUmZtwLFJK4j." /></figure><h4>Deployments</h4><p>We used a great tool to help set up and deploy to some of the serverless tech we’re using.</p><ul><li><a href="https://claudiajs.com/">Claudia.js</a></li></ul><h3>Setting up the Alexa Skill</h3><h4>Alexa Skills Kit Concepts</h4><p>If you have used AWS before, you may be surprised to find out that Amazon has an entirely separate developer platform for managing the development lifecycle of Alexa “skills”. To set up a new Alexa Skill you’ll need to navigate to <a href="https://developer.amazon.com/alexa-skills-kit">https://developer.amazon.com/alexa-skills-kit</a>. There you’ll find resources and instructions for setting up things like</p><ul><li>Skill name</li><li>Regional availability</li><li>Branding and description</li><li>Interaction model</li><li>Linking of your lambda function</li></ul><p>In the Alexa Skills Kit dashboard you’ll also find the “interaction model”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FKHgDaP22x0Xp8OH." /><figcaption>Interaction Model Dashboard</figcaption></figure><p>This is where the interface the users will interact with is set up. Because there is no screen with most Alexa enabled devices, you aren’t building a traditional “drawn” user interface. Instead, you’re creating routes of possible dialogue between your user and Alexa. This is accomplished through a set of abstractions defined by the <a href="https://developer.amazon.com/docs/custom-skills/custom-interaction-model-reference.html">Alexa Skills Kit</a>, and includes concepts like “intents” and “utterances”.</p><p>The power of the Alexa system over voice assistants that came before it, is that Alexa can interpret the many different ways you might make the same request, and still achieve the desired outcome. If you say “Alexa, how’s the weather?” or alternatively, “Alexa, what’s it like outside?”, each of these distinct utterances triggers the same intent, which is to have Alexa describe the current local weather.</p><p>You can use different tools to help you build out robust utterances mapped to intents, to help capture all the different ways your users might make requests. Amazon has a tool called <a href="https://developer.amazon.com/docs/custom-skills/use-the-skill-builder-beta-to-define-intents-slots-and-dialogs.html#navigating-in-the-skill-builder-beta">Skill Builder</a> available in the interaction model panel, and there is <a href="https://github.com/alexa-js/alexa-app-server">Alexa-App-Server</a>, a node.js module with features that help you test, host, and deploy your alexa app code as well as build the utterances you’ll need.</p><p>For an example of how utterances trigger (via an intent) the desired action in the Xero skill that we built, let’s take a look at the index.js file in <a href="https://github.com/XeroAPI/xdhax-alexa-sample">xdhax-alexa-sample</a>/<a href="https://github.com/XeroAPI/xdhax-alexa-sample/tree/master/xbot-alexa-skill">xbot-alexa-skill</a>/index.js.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/859901deb8b916453358eea0f71c2686/href">https://medium.com/media/859901deb8b916453358eea0f71c2686/href</a></iframe><p>You’ll see the utterances that will trigger this intent — any ordered combination of one word in each curly brace. An example of one that would work is “Alexa ask Xero, which org am I attached on?”.</p><p>Once the intent is triggered, it runs through the code we have defined in the getOrgName() method. First we’re checking the status of the session connected to Xero, then using our data helper class to get the org name from Xero’s API endpoint <a href="https://developer.xero.com/documentation/api/organisation">/Organisation</a>. If we can get the organization name then we use our data helper to plug the name into a response and speak it to the user. Here’s that bit of code in our data helper class <a href="https://github.com/XeroAPI/xdhax-alexa-sample">xdhax-alexa-sample</a>/<a href="https://github.com/XeroAPI/xdhax-alexa-sample/tree/master/xbot-alexa-skill">xbot-alexa-skill</a>/xeroDataHelper.js:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f772f39260dc631cc363bc71753c2d1c/href">https://medium.com/media/f772f39260dc631cc363bc71753c2d1c/href</a></iframe><p>You’ll see that we also set the “shouldEndSession” property to false, since we offer to give a weekly status report after delivering the org name. This allows the user to simply say “weekly status report” immediately thereafter, instead of having to say “Alexa ask Xero to give me my weekly status report”.</p><h3>Deployment Process</h3><p>So how do we go about getting all of this code up and running for our users around the world?</p><p>First we’d use <a href="https://vimeo.com/156232471">Claudia.js</a> to deploy our node.js code into a properly configured AWS lambda function and API Gateway. Once the zip file of the lambda function was up in AWS, we’d take note of the ARN (Amazon Resource Name) in the upper right corner of the dashboard and be sure to copy and paste it into our Alexa Skills Kit configuration page for our skill. Here’s a <a href="https://developer.amazon.com/alexa-skills-kit/alexa-skill-quick-start-tutorial">short tutorial</a> from amazon about this process.</p><h3>Xero Account Linking</h3><p>In order to get useful data to your user about their business, you’ll need to enable your Alexa Skill to link to their Xero subscriber account.</p><h4>OAuth</h4><p>If you’ve created an integration using one of Xero’s API’s before, you’ll know that we use the very secure 3-legged OAuth 1.0a protocol. If you’ve never implemented a 3-legged OAuth flow before we’d recommend first taking a look at some helpful primers like <a href="http://oauthbible.com/#oauth-10a-three-legged">this one</a>, and then using a <a href="https://developer.xero.com/documentation/libraries/overview">Xero SDK</a> or other OAuth helper library to do the heavy lifting.</p><p>Because the 3-legged OAuth flow is not a simple workflow to start with, combining it to work with cutting edge serverless infrastructure technologies is not a simple task either, but it is by no means prohibitively hard. Here we’ve diagramed the broad architecture we used for linking our Alexa Skill with a Xero subscriber account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_JEbfAYQL1tvmSwp." /></figure><p>When the user enables our X-Bot skill from the store, they trigger the normal initial token request which routes through our API gateway and lambda function, which because of it’s serverless (i.e. stateless) nature needs to use DynamoDB to store some temporal data about where we’re currently at in the OAuth flow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VqLGcFJUvS3I5Dru." /></figure><p>Our lambda function uses that temporal data, when the user authorizes — hitting the API gateway again, to finalize the OAuth flow and deliver the access token to the Alexa callback URL. The details of how we implemented this account linking are available in the account linking directory of the github repo <a href="https://github.com/XeroAPI/xdhax-alexa-sample/tree/master/alexa-xero-linking-service">here</a>.</p><h3>Conclusion</h3><p>In conclusion, I hope you found this post a useful intro to</p><ul><li>Alexa Skills Kit concepts</li><li>Deploying node.js projects to serverless infrastructure</li><li>Linking a custom Alexa Skill to a Xero account using OAuth</li></ul><p>We were inspired to make this sample project as voice assistants have now entered the mainstream and more and more of our small business customers look to them for up to the minute information about the world. Xero has worked hard to bring the most important information to the surface for our small business owners and their bookkeepers. We hope that this sample project inspires developers to build off of it and create never before seen voice tools that leverage the Xero API and platform.</p><blockquote>This project was created for and presented at Xero’s Developer Roadshow 2017, also known as <a href="https://developer.xero.com/xd17">#XD17</a>. XD17 was presented in partnership with Amazon Web Services (AWS).</blockquote><p>To get started creating a Xero — Alexa Skill of your own, clone this <a href="https://github.com/XeroAPI/xdhax-alexa-sample">sample project repo</a> from the Xero Developer API Github. To see about getting started using the Xero API in general, check out our <a href="https://developer.xero.com/documentation/getting-started/getting-started-guide">getting started guide</a> in the developer portal.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d900469b06f3" width="1" height="1" alt=""><hr><p><a href="https://devblog.xero.com/alexa-skills-and-the-xero-api-d900469b06f3">Alexa Skills and the Xero API</a> was originally published in <a href="https://devblog.xero.com/">Xero Developer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>