Alexa Skills - get custom slot names using Flask-Ask

https://shkspr.mobi/blog/2019/06/alexa-skills-get-custom-slot-names-using-flask-ask/

Amazon encourages developers to use Flask-Ask - the handy Python library for working with Alexa. Sadly, the project has been abandoned. They no longer take pull requests, you can't raise bugs against it, and the documentation is incomplete.

So this is how I solved an annoying problem - how to get the name of a custom slot.

Here's the code, with a fuller explanation afterwards.

from flask import Flask, render_template, requestfrom flask_ask import Ask, statement, question, sessionapp = Flask(__name__)ask = Ask(app, '/')@ask.intent("YourIntentName")def your_intent_name(): content = request.get_json() name = content['request']['intent']['slots']['YOUR_SLOT_NAME']['resolutions']['resolutionsPerAuthority'][0]['values'][0]['value']['name']

Yeuch! What's going on?

Alexa lets us define custom slot names - these can be associated with any spoken text. For example, I might want the slot name "car" to be sent whether the user says "car" or "automobile" or "vehicle" or any other synonym.

In my case, I want to send my API the ID Code of a hospital.

If the user says "John Radcliff" or "Oxford" or "John Radcliff Hospital" - then my API should receive the ID RTH08. It can then use that ID in a separate API call.

Here's the JSON that Alexa sends our API (I've truncated it for ease of reading).

{ "request": { "type": "IntentRequest", "requestId": "amzn1.echo-api.request.1234", "timestamp": "2019-06-17T06:54:52Z", "locale": "en-GB", "intent": { "name": "CarPark", "confirmationStatus": "NONE", "slots": { "hospital": { "name": "hospital", "value": "John radcliff", "resolutions": { "resolutionsPerAuthority": [ { "authority": "amzn1.er-authority.echo-sdk.amzn1.ask.skill.1234.hospitals", "status": { "code": "ER_SUCCESS_MATCH" }, "values": [ { "value": { "name": "RTH08", "id": "abc123" } } ] } ] }, } } } }}

A bit verbose, but easy enough to parse.

I've moaned before about Alexa skill development - but it is getting worse. As you can see from the above screenshot, the development website's contrast isn't great - which makes building a skill physically painful.

Add to that the outdated tutorials, the weird terminology, the multiple sites to use, broken links, and abandoned libraries... It's hard to feel enthusiastic about building more skills.

Amazon have gone down the classic route of paying developers to build for their platform. But I don't think that's enough.

The Alexa team need to work on the developer experience. A GUI like NODE-RED could be used to help build skills in one place. Why is it so complicated to deploy and test skills? Where are the official libraries which "just work"?

I honestly believe that one of the things holding back voice assistants from their full potential is the poor developer experience.

#alexa #developer #hackday #nhshd #python

Alexa Skills - get custom slot names using Flask-Ask

Amazon encourages developers to use Flask-Ask - the handy Python library for working with Alexa. Sadly, the project has been abandoned. They no longer take pull requests, you can't raise bugs against it, and the documentation is incomplete. So this is how I solved an annoying problem - how to get the name of a custom slot. Here's the code, with a fuller explanation afterwards. Python 3from…

Terence Eden’s Blog

Wishing everyone at #nhshackday my today creative minds, clean data and smooth debugging. I can’t wait to see what you all make!

#NHSHD

We won! #nhshackday #nhshd25

"The judges commented they felt our real-world problem was demonstrable, the solution practical and we had consiered the wider factors allowing to tackle the Q&A."

#nhshd #nhs #VictoriaParkMassif
https://social.coop/@ollybenson/111233603756538462

Olly Benson (@[email protected])

Attached: 1 image Good day so far at #NHSHackDay in Leicester. We're working on a way to pre-register international students who are coming to the UK to study so that they collect relevant health information before they arrive here. #nhs #nhshd25

social.coop
NHS Hack Day

It has been about 6 months since I started my new job at NHSX – I’ve loved getting stuck in to the Health Service culture. But there was one thing I was missing… a decent hack day…

Terence Eden’s Blog
Alexa Skills - get custom slot names using Flask-Ask

Amazon encourages developers to use Flask-Ask - the handy Python library for working with Alexa. Sadly, the project has been abandoned. They no longer take pull requests, you can't raise bugs against it, and the documentation is incomplete. So this is how I solved an annoying problem - how to get the name of a custom slot. Here's the code, with a fuller explanation afterwards. Python 3from…

Terence Eden’s Blog

‪There were loads of other amazing innovations — see @amCunningham’s thread for more — and it was challenging indeed to pick winners.‬

Thanks to the organisers and volunteers, and to all those who hacked. Your creativity & skills are inspiring!

https://twitter.com/amcunningham/status/1140260511268921344

#nhshd ‪10/10‬

Anne Marie Cunningham on Twitter

“#nhshd First up - Patient Record Matching - here is their presentation https://t.co/31QcExuAWd”

Twitter

‪— and used SVG from KML files to create a map at the top of each card, representing the area.‬

‪We were particularly impressed with the volume of work they accomplished in just two days, and their ability to communicate complicated subjects (the various things that make CAMHS services successful or challenged, and how each region compares to others) in a fun and engaging way. ‬

#nhshd 9/‬

‪Honourable mention: NHS Top Trumps‬

‪The team dynamically generated top trumps cards reflecting child and adolescent mental health statistics from each local authority.‬

‪They used python for the data wrangling and to create the cards, pushed the data into CSV where they could manage it, —‬

#nhshd 8/‬

‪— including with a video from the clinician that the patient could examine at home. ‬

‪The app then produced a PDF that could be emailed to patient or clinician, and they aimed to remove thousands of kilogrammes of paper from the system.‬

#nhshd 7/‬

‪3rd prize: Consent reimagined‬

‪They created a web app to let patient and clinician electronically build a customised consent form, for a patient to understand risk in and agree to a procedure.‬

‪The app had interfaces for the clinician to customise the content for the patient, and for the patient to review it —‬

#nhshd 6/‬