Giter Site home page Giter Site logo

raspiasteriskalexa's Introduction

RaspiAsteriskAlexa

Integrating Asterisk with Amazon Alexa Voice Service on a Raspberry Pi Zero using AGI

Important Note: This can only be used as a proof-of-concept. It currently does not meet the Amazon Voice Service Agreement for Public or Commercial application. See https://developer.amazon.com/support/legal/alexa/alexa-voice-service/terms-and-agreements for more details.
It does meet requirements for home or experimental (private) use. To keep it private, the Asterisk configuration files here default to an internal Asterisk extension only.

Also available: Google Voice Assistant running on Asterisk PBX on a Pi. https://github.com/rgrokett/RaspiAsteriskGoogle

Note that Amazon changes SDK and security req often, may cause issues here.

2021 Update: Incredible PBX for Asterisk has added this feature and updated for easier installation! Go to: https://nerdvittles.com/amazons-alexa-now-available-for-incredible-pbx-2020/

Overview

This requires an account with Amazon and Amazon Voice Services: https://developer.amazon.com/public/solutions/alexa/alexa-voice-service

Also required is:

  • Raspberry Pi (Zero, B+, 3, etc.) running Raspian Jessie (or newer)
  • Asterisk PBX ( $ sudo apt-get install asterisk )
  • A bunch of packages (see the Installation document in Github)
  • The files from Github
  • Your Voice Service authorized in Amazon Voice Services
  • https://developer.amazon.com/en-US/docs/alexa/alexa-voice-service/authorize-cbl.html
  • (This solution uses Amazon Implicit Grant method of authentication so follow only its steps.)

Note that the Amazon Authorization is the most complicated part of this project. See Installation doc for details.

Alternate RasPBX (FreePBX) Usage

If you are a FreePBX (RasPBX) user, you can apply the following changes as shown from jimbolaya:

*jimbolaya commented:

I got this running on RasPBX. I skipped the sections until I got to "Alexa/Asterisk Install and Configuration" since I already had a running setup on RasPBX.

I ran install.sh from /usr/src/RaspiAsteriskAlexa. I probably should have just done it by hand. In the instructions I replaced "/usr/share" with "/var/lib" which is where the asterisk sound directory and the agi-bin directory reside. This includes a path within .../asterisk/agi-bin/alexa.agi

There is no .../sounds/custom directory, so I had to create that with appropriate permissions.

For setting up the "AMAZON ALEXA VOICE" extension, the file for the custom extension is different. In FreePBX, the custom extensions live in "/etc/asterisk/extensions_custom.conf". I added the [alexa_tts] to this file and:

[ext-local-custom]
include => alexa_tts
below the [alexa_tts] section

RasPBX doesn't seem to have a pi user, but that doesn't seem to be needed. I did create one anyway and copied the RaspiAsteriskAlexa directory there just in case.

raspiasteriskalexa's People

Contributors

r0bi avatar rgrokett 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

raspiasteriskalexa's Issues

Not able to get Token

I I have been following the instructions to get the project installed on my PiZeroW running RasPBX. I get to the part about getting my token and I am able to sign in, it asks for permission and when I click allow I am getting an error occurred with the login request. Am I supposed to get the token by running the URL on the PiZeroW, and how since RasPBX doesn't have a desktop or browser. Plus the URL you give us didn't get me to the login page. I had to change it and go to: https://www.amazon.com/ap/oa?client_id=YOURCLIENTID&scope=alexa%3Aall&response_type=token&redirect_uri=http://localhost.

Thanks.

Just a loop of ask an other question

Of Asterisk answers the call it starts with the Example ans after this I can‘t das anything because a Loop of „Ask an other question starts“! A reinstall of the pi doesn‘t solved the problem.

Thanks

Typo in grant_token.sh

grant_token.sh has an error

-d option is a "long -" and needs to be fixed or the script does not run

I found another of these "long " in the PDF docs while copying and pasting commands as well but do not remember exactly where

Any idea what terms this (currently) falls foul of with AVS?

What a great project! But in your README, you say (added 4th August 2016):

Important Note: This can only be used as a proof-of-concept. It currently does not meet the Amazon Voice Service Agreement for Public or Commercial application. See https://developer.amazon.com/edw/avs_agreement.html for more details. It does meet requirements for home or experimental (private) use.

Before I go too far down the road of a project, do you know WHY this would not meet the agreement?

From digging through the terms (which have now moved to https://developer.amazon.com/public/solutions/alexa/alexa-voice-service/support/terms-and-agreements), I found the following, which is where I guess the issue lies:

(b) Your Product will transmit responses delivered by the Alexa Service directly to the end user immediately upon receipt of the response;

(c) you will not collect or store copies of any audio, transcripts, voice or other interactions either intended for or delivered by the Alexa Service;

The problem here is that, necessarily, there will be a path that involves a trans-code of the 8 bit ulaw/alaw.

Also

Alexa Voice Service Program Requirements

Section 2 (q) you will not allow an end user of Your Product to access the Alexa Service through Your Product during a voice communication occurring on or through Your Product (such as a phone call) without Amazon’s prior written approval, and any such implementation may be subject to additional terms and conditions;

However, there is also this, written AFTER your README - do the following make any material difference?

Changes to Alexa Agreement

Changes posted August 23, 2016.

We’ve updated the Alexa Agreement to remove the requirement that you obtain Amazon’s written approval prior to implementing far-field voice recognition or use of a spoken word to trigger the activation of the Alexa Service in Your Products, and to make other updates. Please review the full text of the updated Alexa Agreement carefully.

Changes posted January 30, 2017.

We’ve updated the Alexa Agreement to add Amazon Media EU S.à r.l. as an Amazon Party and to reflect the launch of the Alexa Voice Service Program in the United Kingdom and Germany. Please review the full text of the updated Alexa Agreement carefully.

I tried asking another Alexa dev, and he said that as far as he is aware, Alexa requires a "one to one" relationship with the end user, but he thinks AVS could be used to interpret intent.

That said, I wonder if LEX is the safe way to go? This StackOverflow answer seems to suggest so,
https://stackoverflow.com/questions/43696952/difference-between-amazon-lex-polly-vs-alexa-voice-services-alexa-skill-k

Also, it seems like Lex has a similar use of Lambda and slots and intents. so perhaps Lex and Polly is the answer?
http://docs.aws.amazon.com/lex/latest/dg/lambda-input-response-format.html

Have you looked into this? What do you think? If you think this might work and haven't already done it, I'd be happy to help!

Extension flow looping

This is an awesome project, thanks for making it!

Just trying to get this going so I'm not sure it's an issue. I've got the PBX all set up and working on a docker container instead of a RasPi.

When I dial the 5555 extension, the answer plays but doesn't wait to record and loops indefinitely on "Try another question". It doesn't appear that token.pl is being run as there are no /tmp/token* files being generated (this does work running manually). The asterisk logging is pretty average, so I can't tell what's wrong.

Here's my sip.conf:

[internal]
exten => 7001,1,Answer()
exten => 7001,2,Dial(SIP/7001,60)
exten => 7001,3,Playback(vm-nobodyavail)
exten => 7001,4,VoiceMail(1000@7001)
exten => 7001,5,Hangup()

exten => 7002,1,Answer()
exten => 7002,2,Dial(SIP/7002,60)
exten => 7002,3,Playback(vm-nobodyavail)
exten => 7002,4,VoiceMail(7002@main)
exten => 7002,5,Hangup()

exten => 8001,1,VoicemailMain(7001@main)
exten => 8001,2,Hangup()

exten => 8002,1,VoicemailMain(7002@main)
exten => 8002,2,Hangup()

include => alexa_tts
include => default

; AMAZON ALEXA VOICE
[alexa_tts]
exten => 5555,1,Answer()
; Get an AWS Token
exten => 5555,n,System(/root/token.pl)
; Play prompts
exten => 5555,n,Playback(./custom/alexa_hello)
exten => 5555,n,Playback(./custom/alexa_example)
; Alexa API integration
exten => 5555,n(record),agi(alexa.agi,en-us)
; Loop
exten => 5555,n,Playback(./custom/alexa_another)
exten => 5555,n,goto(record)
; These are not used currently
exten => 5555,n(goodbye),Playback(vm-goodbye)
exten => 5555,n,Hangup()

Will Alexa work on an Old Asterisk version

Aloha
I wanted to try an incorporate your Alexa build into a radio communications project that runs an older version of Asterisk. https://www.hamvoip.org/ We use the Pi and Asterisk to run a radio repeater controller and thought your Alexa project would make a nice add-on. Can you also load additional Alexa skills to the development profile. Any guidance you can provide would be helpful I think this will be a great PI project.
Thanks
Gary

Can't seem to get

After going through

  1. Copy the URL below to a notepad and EDIT to insert your client_id and Paste to your browser.
    https://www.amazon.com/ap/oa?client_id=YOURCLIENTID&scope=alexa%3Aall&scope_data=%7B%22alexa%3Aall%22%3A%7B%22productID%22%3A%22kd_raspi_asterisk%22,%22productInstanceAttributes%22%3A%7B%22deviceSerialNumber%22%3A%2212345%22%7D%7D%7D&response_type=code&redirect_uri=https%3A%2F%2Flocalhost

with my own YOURCLIENTID I never get to the page that has the "https://localhost ..." part in it. It always goes to another screen:

We're sorry!
An error occurred when we tried to process your request. Rest assured, we're already working on the problem and expect to resolve it shortly.

Is this an issue with Amazon? I'm not sure how else to get a provisioning token. I'll do some research on that.

Source for PDF file to allow copying long URLs

if you would, please include the source document for the PDF or a text file containing the long template URLs so they can easily be copied and pasted, thanks!

Hmm, turns out is the firefox pdf viewer that makes copying impossible, so no source needed!

WAV format mismatch

[Nov 17 13:04:07] WARNING[9238][C-00000022]: format_wav.c:112 check_header_fmt: Unexpected frequency mismatch 16000 (expecting 8000)
[Nov 17 13:04:07] WARNING[9238][C-00000022]: file.c:398 fn_wrapper: Unable to open format wav
-- Playing '/tmp/avs_audio9265' (escape_digits=#) (sample_offset 0)

PDF

Having the instructions in a PDF file makes this more complicated than it needs to be. Can’t copy and paste long text strings and have to type by hand this way, making it a lot easier to screw up. Any number of other file types, such as RTF would have been better. Any word processor can open an RTF file.

Getting RaspiAsteriskAlexa to run on RasPBX/FreePBX

I'm sorry this isn't really an issue, more of a howto.

First off, thank you for doing this. This is one of the coolest projects I've ever done. Also thank you for updating the instructions for getting the tokens.

I got this running on RasPBX. I skipped the sections until I got to "Alexa/Asterisk Install and Configuration" since I already had a running setup on RasPBX.

  1. I ran install.sh from /usr/src/RaspiAsteriskAlexa. I probably should have just done it by hand.
  2. In the instructions I replaced "/usr/share" with "/var/lib" which is where the asterisk sound directory and the agi-bin directory reside. This includes a path within .../asterisk/agi-bin/alexa.agi
  3. There is no .../sounds/custom directory, so I had to create that with appropriate permissions.
  4. For setting up the "AMAZON ALEXA VOICE" extension, the file for the custom extension is different. In FreePBX, the custom extensions live in "/etc/asterisk/extensions_custom.conf". I added the [alexa_tts] to this file and:
[ext-local-custom]
include => alexa_tts

below the [alexa_tts] section

RasPBX doesn't seem to have a pi user, but that doesn't seem to be needed. I did create one anyway and copied the RaspiAsteriskAlexa directory there just in case.

If you want to add this to the Wiki or as a Readme that would be fine or I can do it in a commit (though I've never done that before).

AsteriskAlexa

I see little reason as to why this is called "Raspi....." as it runs beautifully on my ubuntu 12.04 / asterisk 11 box , even the installer script.

The only thing I had to do was create an alias of /home/pi that pointed to my real home directory

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.