Search code examples
pythonamazon-web-servicesflaskalexa-skills-kitflask-ask

How can I trigger Alexa intent with clicks rather than voice?


I am working on a flask app that links to Alexa skills. I am trying to building a capability when a user click on some content (e.g. notifications), Alexa asks if the user wish to proceed, if the user says 'yes', then Alexa takes the user to the relevant webpage.

My question is, is it possible to trigger Alexa intent with clicks on the website content instead voice? My understanding that intent can only be activated through voice.

Any thoughts will be much appreciated.


Solution

  • As you say the intent is triggered by voice. A relatively easy way to do it would be:

    Generate the audio file expressing the intent using polly tool. E.g. "play my song" https://docs.aws.amazon.com/polly/latest/dg/API_SynthesizeSpeech.html

    Whenever the user clicks on the web link, invoke the intent using the PostContent API. Basically pretending the user said it.

    An example of invocation would be:

    aws lex-runtime post-content  --bot-name yourBot --bot-alias \"\\$LATEST\"  --user-id youruserid--content-type \"audio/l16; rate=16000; channels=1\"  --input-stream request.wav answer.mp3
    

    where yourBot is your Bot name and request.wav is the audio file previously generated with polly. You will get the audio answer in the file answer.mp3

    Drawback is you need to use lex/lambda for this, not just flask... Hope it helped! Ester