Code Monkey home page Code Monkey logo

alexa-monzo's Introduction

Monzo for Alexa CircleCI

This project provides an Alexa Skill for the Monzo card/bank - It allows users to query their bank balance and spending history simply and easily with just their voice.

Demo of Monzo Skill for Alexa

Setting up a development environment

  • Clone the repository
  • Run npm install
  • Zip everything in the folder (including the node_modules folder!)
  • Set up a AWS Lambda function, and choose to upload the code as a ZIP.
  • Go to the Alexa Developer Site and create a new Alexa Skills Kit skill.
  • Use whatever you like for the application name and invocation name
  • Set up the Interaction model using the schema defined in the alexa_schema folder
  • On the configuration page
    • Set the service endpoint to use the ARN from the Lambda function you set up above
    • Enable Account Linking
    • Set the Authorization URL to https://auth.getmondo.co.uk/
    • Set the client ID to the ID given by Monzo's OAuth client registration
    • Copy one of the Redirect URLs into the Redirect URI of your Monzo OAuth Client
    • Set Authorization Grant Type to Auth Code
    • Set Access Token URI to https://api.monzo.com/oauth2/token
    • Set Client Secret to the secret given by Monzo's OAuth client registration
  • Enable the skill for testing on your own Alexa
  • Develop!

Troubleshooting

If you're having difficulty linking your account to Alexa using the Alexa app on iPhone, try instead using https://alexa.amazon.co.uk/ through a desktop or mobile browser (Avoiding any built-in WebViews if possible).

If you recieve Unable to import module 'module' in your CloudWatch logs after uploading the zip to AWS Lambda, then the structure of your zip might be in a format that Lambda doesn't expect. Your zip must not contain just a folder at its top level, it must contain index.js on the top-level.

alexa-monzo's People

Contributors

geit avatar ojford avatar rpmhoward avatar samvaughton avatar vin047 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

alexa-monzo's Issues

Implement Amazon.HelpIntent

When a user asks for help, Alexa should respond with a brief message giving a high level overview of available functionality.

Add prefetch for some API functionality

When the application is stateful, it might be an idea to prefetch and cache some responses after Alexa has responded if we expect the user might ask for more details. This would improve percieved performance.

Intents must have all slots they are defined with within their sample utterances

GetSpendingHistory is defined with two slots, but some of its sample utterances only define one slot. GetSpendingHistory needs to be seperated into two seperate Intents, with the appropriate number of slots corresponding in their utterances. They can still direct to a single handler on the back-end to avoid code duplication.

Make application stateful

Add stateful features to the application. For example, when asking Monzo how much I've spent today, the application should ask if I want a more detailed break down after she's read the balance.

Slots must be enriched

Currently only the basic Monzo categories are defined within the transaction_category slot. Any synonyms that a user might potentially use in that slot should also be included. We will also have to map these back into the appropriate category in the backend.

Slots can also not contain unpronouncable characters, such as underscores

Create a dictionary of varied responses

Currently Alexa always responds with the exact same phrase for a given input, we should try and define a large dictionary of phrases with equivilent meaning that Alexa can then pick from at random. This would help Alexa to feel more like a real person, rather than just a robot.

Display cards in the Alexa app

When we respond with information about the user's bank balance or spending history, we should also put a card with that information (and a link to the monzo app? If there's documentation on the Monzo URI protocol) into the Alexa app.

Add cache to common API requests

Currently we send a request off to the Monzo API for account details every time an interaction takes place with the application, the account API has a standard latency of 125~250ms. This response could be cached for a short time to improve perceived performance when interacting with Alexa.

Authorising the skill

I'm having terrible difficulty authorising the Alexa skill.

I just keep getting a message saying that the skill can't be authorised and to try again later.

Any help would be appreciated.

Thanks!

The remote endpoint could not be called, or the response it returned was invalid.

Having trouble testing the skill - when I try a few of the sample utterances, I get the above error. Not sure if it's related, but in the lambda console when I try to run a simple test, I get the following error:

{
  "errorMessage": "Cannot find module '/var/task/index'",
  "errorType": "Error",
  "stackTrace": [
    "Module.require (module.js:353:17)",
    "require (internal/module.js:12:17)"
  ]
}

Any ideas what I could be doing wrong?

Edit: I'm guessing it's down to what I've labelled as the handler. I've tried index.handler (as above), Alexa, alexa, alexa-monzo, and monzo.

Ask Alexa if you're within your targets

Target can be retrieved from the /targets?account_id=$account_id endpoint, and the response format at the time of writing is as follows:

{
    "currency": "GBP",
    "interval": {
        "end": "2016-10-31T23:59:59.999Z",
        "start": "2016-09-30T23:00:00Z"
    },
    "interval_type": "month",
    "targets": [
        {
            "amount": 36000,
            "name": "eating_out",
            "status": "OKAY",
            "type": "category"
        },
        {
            "amount": 70000,
            "name": "total",
            "status": "OKAY",
            "type": "total"
        }
    ]
}

Ask Alexa to set a target

Targets API is currently undocumented, so direct user to the app to set targets. In future we could try and parse and set a target for a time period.

Increase number of sample utterances for each intent

Currently each intent has a few variations of sample utterance (23). To meet Amazon guidelines, there need to be around 1520 for each(!).

Small variations do apply however, for example

GetBalance   what my balance is
GetBalance   what my balance is please
GetBalance   what is my balance
GetBalance   what is my balance please
GetBalance   how much do I have
GetBalance   how much do I have today
GetBalance   how much money is on my account
GetBalance   how much money is on my card
...

Add a flash briefing skill

Not sure if they're currently supported on the UK Alexa, but a flash briefing API skill for Monzo would be cool.

It could give you a summary of todays/yesterdays spending (depending on the time day?)

If card already (un)frozen, ask user if they want to toggle its state

Currently Alexa sometimes gets confused between the two intents for UnfreezeCard/FreezeCard - so users may trigger one, while actually wanting the other. To minimize the annoyance of this, Alexa should ask if they want to toggle the state, rather than just bailing out.

  • This would require setting up state on the Amazon.YesIntent and Amazon.NoIntent, so we know which handler to use immediately after a user has triggered FreezeCard/UnfreezeCard

Add a LaunchRequest intent

We could use the LaunchRequest to prefetch some key information about the user, as it likely means they'll be using the application shortly.

Add ability to (un)freeze card

You should be able to (un)freeze your card from the Alexa. A notification/feed item should be pushed to Monzo when this happens, in case the card was frozen by a nefarious family member

GetTransactions method limited to 100 transactions

The Monzo API only returns the last 100 transactions by default. When we're checking spending history we only get transactions from that default response, which may not be representative of someone's full spending history.

If there are >100 transactions in a time period we should iterate over the API method till we're sure we've got all transactions for the time period.

Ask Alexa for user details

A fairly simple one: the /profile endpoint returns a response in the format:

{
  "address": {
    "administrative_area": "",
    "country": "GBR",
    "formatted_address": "",
    "locality": "London",
    "postal_code": "WS1",
    "street_address": [
      "221b Baker Street",
    ]
  },
  "date_of_birth": "YYYY-MM-DD",
  "email": "[email protected]",
  "name": "Alexander Example",
  "phone_number": "+44xxxxxx",
  "user_id": "user_xxxxxxxxxx",
  "user_number": 1
}

Alexa could respond simply with the user number.

Add CI

My trivial and seemingly-innocuous PR never had tests run against it, and they broke (#15).

Not a huge deal, but Travis/Circle/anything running tests against PRs would have prevented it :)

Unable to link your skill

Hey,

I keep getting "Unable to link your skill" errors any idea what I'm doing wrong?

In monzo I've set the redirect urls to "https://layla.amazon.co.uk/api/skill/link/M2ZMQNS2VXCBTQ" and confidential set to true

In the alexa skill I've got

  • client ID: "oauthclient_00....."
  • the 2 urls are correct
  • the Client Authentication Scheme is set to "Credentials in request body"

If I open the email from monzo on my phone alexa app opens and there's no confirmation and the "Link account" button still shows. If I open it on my laptop I get the unable to link your skill error.

Any pointers would be much appreciated,
Cheers
Steve

"sorry - something went wrong"

All seems good when I try my skill in the developers console, but when I try it on an actual device I just get "sorry something went wrong".

Any tips of where to start debugging? Or do I just need to be patient and wait for it to update on all my devices? (If that's a thing?)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.