martin-riedl / CALexa

CALexa is an Amazon Alexa Skill which allows accessing CalDAV Calendars. It makes use of the Flask-Ask Python micro-framework developed by John Wheeler.
Apache License 2.0
34 stars 10 forks source link

Outdated .json and to less Information in readme #5

Open Phil-Rei opened 6 years ago

Phil-Rei commented 6 years ago

Hi, first of all I want to thank Martin Riedl for sharing his code. I've tried to install it on my system and had several problems, but got pretty far (I guess almost 99%).

My System: Xubuntu 16.04, OwnCloud 10.0.8, Apache 2, Cert via Let's Encrypt

Step one: Alexa Skill on Amazon Dev: It seems Amazon changed their syntax some time ago. The provided .json is not accepted as it is. I've transformed it to the following which already includes all speech_assets and customSlotTypes... So you basically only need to paste the .json and don't need to add these things manually any more.

{
    "interactionModel": {
        "languageModel": {
            "invocationName": "calexa",
            "intents": [
                {
                    "name": "GetEventsIntent",
                    "slots": [
                        {
                            "name": "Date",
                            "type": "AMAZON.DATE"
                        },
                        {
                            "name": "EndDate",
                            "type": "AMAZON.DATE"
                        },
                        {
                            "name": "EventSynonyms",
                            "type": "LIST_OF_EVENT_SYNONYMS"
                        },
                        {
                            "name": "CalendarSynonyms",
                            "type": "LIST_OF_CALENDAR_SYNONYMS"
                        }
                    ],
                    "samples": []
                },
                {
                    "name": "SetEventIntent",
                    "slots": [
                        {
                            "name": "Date",
                            "type": "AMAZON.DATE"
                        },
                        {
                            "name": "Time",
                            "type": "AMAZON.TIME"
                        },
                        {
                            "name": "Duration",
                            "type": "AMAZON.DURATION"
                        },
                        {
                            "name": "EndDate",
                            "type": "AMAZON.DATE"
                        },
                        {
                            "name": "EventSynonyms",
                            "type": "LIST_OF_EVENT_SYNONYMS"
                        },
                        {
                            "name": "CalendarSynonyms",
                            "type": "LIST_OF_CALENDAR_SYNONYMS"
                        },
                        {
                            "name": "eventtype",
                            "type": "LIST_OF_EVENT_TYPES"
                        }
                    ],
                    "samples": []
                },
                {
                    "name": "AMAZON.HelpIntent",
                    "samples": []
                },
                {
                    "name": "AMAZON.StopIntent",
                    "samples": []
                },
                {
                    "name": "AMAZON.CancelIntent",
                    "samples": []
                },
                {
                    "name": "Calexa",
                    "slots": [
                        {
                            "name": "EventSynonyms",
                            "type": "LIST_OF_EVENT_SYNONYMS"
                        },
                        {
                            "name": "Date",
                            "type": "AMAZON.DATE"
                        },
                        {
                            "name": "CalendarSynonyms",
                            "type": "LIST_OF_CALENDAR_SYNONYMS"
                        },
                        {
                            "name": "EndDate",
                            "type": "AMAZON.DATE"
                        },
                        {
                            "name": "eventtype",
                            "type": "LIST_OF_EVENT_TYPES"
                        },
                        {
                            "name": "Time",
                            "type": "AMAZON.TIME"
                        },
                        {
                            "name": "Duration",
                            "type": "AMAZON.DURATION"
                        }
                    ],
                    "samples": [
                        "SetEventIntent einen {eventtype} um {Time} einzutragen",
                        "SetEventIntent ein {eventtype} für den {Date} um {Time} anzusetzen",
                        "SetEventIntent ein {eventtype} für den {Date} um {Time} über {Duration} einzurichten",
                        "SetEventIntent einen {eventtype} für den {Date} um {Time} von {Duration} anzusetzen",
                        "SetEventIntent ein {eventtype} für den {Date} um {Time} für {Duration} einzurichten",
                        "SetEventIntent einen neuen Termin {eventtype} für den {Date} um {Time} für {Duration} hinzuzufügen  ",
                        "SetEventIntent einen neuen Termin {eventtype} für den {Date} um {Time} für {Duration} anzulegen ",
                        "GetEventsIntent Welche Termine habe ich zwischen dem {Date} und dem {EndDate}",
                        "GetEventsIntent Was habe ich für {EventSynonyms}",
                        "GetEventsIntent Was habe ich am {Date} für {EventSynonyms} im {CalendarSynonyms}",
                        "GetEventsIntent Was habe ich am {Date} für {EventSynonyms}",
                        "GetEventsIntent Was habe ich für {EventSynonyms} {Date}",
                        "GetEventsIntent Was habe ich {Date} für {EventSynonyms}",
                        "GetEventsIntent Gib mir die Ereignisse für {Date}",
                        "GetEventsIntent Gib mir die {EventSynonyms} für {Date}",
                        "GetEventsIntent Gib mir die {EventSynonyms} {Date}",
                        "GetEventsIntent Was ist {Date} auf dem {CalendarSynonyms}",
                        "GetEventsIntent Was ist auf dem {CalendarSynonyms}",
                        "GetEventsIntent Welche {EventSynonyms} stehen im {CalendarSynonyms} zwischen dem {Date} und dem {EndDate} ",
                        "GetEventsIntent Welche {EventSynonyms} stehen im {CalendarSynonyms} zwischen dem {Date} und dem {EndDate} an",
                        "GetEventsIntent Welche {EventSynonyms} stehen zwischen dem {Date} und dem {EndDate} an",
                        "GetEventsIntent Welche {EventSynonyms} stehen {Date} an",
                        "GetEventsIntent Welche {EventSynonyms} ich vom {Date} bis zum {EndDate} auf dem {CalendarSynonyms} habe",
                        "GetEventsIntent Welche {EventSynonyms} ich habe ",
                        "GetEventsIntent Welche {EventSynonyms} ich am {Date} habe ",
                        "GetEventsIntent Welche {EventSynonyms} ich am {Date} auf dem {CalendarSynonyms} habe ",
                        "GetEventsIntent nach meinen {EventSynonyms} vom {Date} zum {EndDate}",
                        "GetEventsIntent nach meinen {EventSynonyms} vom {Date} bis zum {EndDate} ",
                        "GetEventsIntent nach meinen {EventSynonyms} zwischen {Date} und {EndDate}",
                        "GetEventsIntent nach meinen {EventSynonyms}",
                        "GetEventsIntent Welche {EventSynonyms} habe ich {Date}",
                        "GetEventsIntent Welche {EventSynonyms} habe ich am {Date} ",
                        "GetEventsIntent Welche {EventSynonyms} habe ich am {Date} auf dem {CalendarSynonyms}"
                    ]
                }
            ],
            "types": [
                {
                    "name": "LIST_OF_EVENT_SYNONYMS",
                    "values": [
                        {
                            "name": {
                                "value": "Termin",
                                "synonyms": [
                                    "Abmachung",
                                    "Verabredung",
                                    "Event",
                                    "Ereignis"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "LIST_OF_CALENDAR_SYNONYMS",
                    "values": [
                        {
                            "name": {
                                "value": "Kalender",
                                "synonyms": [
                                    "Agenda",
                                    "Terminplaner"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "LIST_OF_EVENT_TYPES",
                    "values": [
                        {
                            "name": {
                                "value": "Besprechung",
                                "synonyms": [
                                    "Party",
                                    "Festival",
                                    "Veranstaltung",
                                    "Vortrag",
                                    "Treffen",
                                    "Meeting",
                                    "Lehre",
                                    "Vorlesung",
                                    "Arzttermin"
                                ]
                            }
                        }
                    ]
                }
            ]
        }
    }
}

Step two: Running calexa.py on same server

I've Downloaded calexa.py and conf/config.json In the config I'm not sure the URL has to be https://domain.de/remote.php/dav/calendars/USERNAME/default/ or https://domain.de/remote.php/dav/principals/users/USERNAME/

So I've tried both (first is my default calendar, second one are all of my calendars).

I've also installed the dependencies via:

pip install flask-ask
pip install caldav
pip install cics

When I run python calexa.py this is the output:

/home/USERNAME/.local/lib/python2.7/site-packages/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
  warnings.warn(warning, RequestsDependencyWarning)
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)

So it seems to run. I've ignored the warning cause it only seems to be a speed issue.

Using a local Browser on http://127.0.0.1:5000 I get this:

Method Not Allowed
The method is not allowed for the requested URL.

Since there is no parameter I've expected some error at least. Calexa.py Output in console add's the following line: 127.0.0.1 - - [25/Jul/2018 10:15:56] "GET / HTTP/1.1" 405 -

Step three: Reach Calexa fom outside Activated proxy module for Apache

sudo a2enmod proxy
sudo a2enmod proxy_http

VirtualHosts:

<IfModule mod_ssl.c>
        <VirtualHost _default_:443>
                ServerName domain.de
                DocumentRoot /var/www/html

                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined

                LimitRequestBody 0

                SSLEngine on
                SSLProxyEngine On

                ProxyPreserveHost On

                ProxyPass / http://localhost:5000

                SSLCertificateFile      /etc/letsencrypt/live/domain.de/cert.pem
                SSLCertificateKeyFile   /etc/letsencrypt/live/domain.de/privkey.pem
                SSLCertificateChainFile   /etc/letsencrypt/live/domain.de/chain.pem

        </VirtualHost>
</IfModule>

Of course Port 433 has NAT forwarding to my server. I'm now able to access from outside, getting the same Method Not Allowed message.

Endpoint in Amazon Dev is: https://domain.de

This is what I get when I try to open Calexa with my Echo Dot. (Alexa starte Calexa)

Bei der Antwort des angeforderten Skill ist ein Problem aufgetreten. Free translated: There was a problem with the answer of the skill.

I can see the requests reaching calexa.py as it outputs the following:

127.0.0.1 - - [25/Jul/2018 10:30:25] "POST / HTTP/1.1" 400 -
127.0.0.1 - - [25/Jul/2018 10:30:26] "POST / HTTP/1.1" 200 -

So it seems I'm almost done. Maybe my conversion of the .json is not correct or the calexa.py is configured wrong. Maybe someone can help and hopefully I can help others with my detailed descriptions.

nikolauskrismer commented 6 years ago

I am also struggeling with the installation of this skill? Was there some progress?

Have you tried testing the skill in the alexa developer console?

nikolauskrismer commented 6 years ago

Ok... I could get it to work somehow (not everything works perfectly... however, I tested basic things and they seem to work)

Have a look at my fork. There you will find a correct json for an interaction model (similar to yours above but without the intent named "Calexa")

Domi1980 commented 5 years ago

Hi all, did anyone find a solution for the behavior described by @Phil-Rei? I also receive the same feedback from calexa.py and could not find a solution for this.

127.0.0.1 - - [25/Jul/2018 10:30:25] "POST / HTTP/1.1" 400 - 127.0.0.1 - - [25/Jul/2018 10:30:26] "POST / HTTP/1.1" 200 -

I'm using the fork of @nikolauskrismer

Thanks in advance.

nikolauskrismer commented 5 years ago

No... I did not experience that problem. Maybe it is possible to increase the log level somewhere...

BTW: Did you tried testing within the Amazon console also or are you using alexa directly for your tests?

Domi1980 commented 5 years ago

I tried testing it with the amazon console. the return is an empty body: { "body": {} }

the console shows the above mentioned HTTP requests and status codes.

Phil-Rei commented 5 years ago

Same here, I've also tried the fork from nikolauskrismer.

* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [11/Sep/2018 11:24:32] "POST / HTTP/1.1" 400 -
127.0.0.1 - - [11/Sep/2018 11:24:32] "POST / HTTP/1.1" 200 -

Alexa Console returns:

{
    "body": {}
}
Garfonso commented 5 years ago

Same issue here. @nikolauskrismer do you also get the status code 400 line in the console?

nikolauskrismer commented 5 years ago

No... not that I remember I also got the empty body and thought that this was a problem... but in fact this seems to be normal

Garfonso commented 5 years ago

What are you asking exactly? I always get either an error message or the message that there is nothing in my calendar. Also, I suspect, in the config you set the URL of a specific calendar (which would also disallow multiple calendars, right?).

polcape commented 4 years ago

Hi, can I take as correct setup all of these settings? Is calexa still working?

Thanks

gstlouisgit commented 3 years ago

It looks like this conversation was years ago. I was really looking forward to setting this up on apache as well. Thanks for the comments everyone posted and shared. I hope someone comments more on a resolution here. @Garfonso @nikolauskrismer @Phil-Rei . This would be amazing to get working!!

polcape commented 3 years ago

Yes, I agree

polcape commented 3 years ago

Hi, I try to use this repository and confirm it works.

I made some changes to use with docker and put code here https://git.cdp.li/polcape/calexa

gstlouisgit commented 3 years ago

@polcape thanks for confirming. I do not have docker but I will try following their instructions on this repo and see if it works. I will only have apache. If you have any comments on problems you had to deal with please let me know.

Garfonso commented 3 years ago

I never got it working... 🙁 Would like to try again. Will see with your setup.

polcape commented 3 years ago

do not have docker but I will try following their instructions on this repo and see if it works. I will only have apache. If you have any comments on problems you had to deal with please let me know.

Hi @gstlouisgit ,

the only thinghs/problems I found was:

The docker image is based on python 3.6 in requirements.txt you find the compatible packages to install. If you don't use docker you can try to start the calexa following that requirements using python 3.6

Also pay attention to use ssl connection or ngrock

Garfonso commented 3 years ago

i, I try to use this repository and confirm it works.

I made some changes to use with docker and put code here https://git.cdp.li/polcape/calexa

Hi,

today I tried to setup your docker. It does not work, I get the following error after the container build and it tried to start:

Successfully built 98d58a166881
Successfully tagged calexa_calexa:latest
WARNING: Image for service calexa was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating calexa ... done
Attaching to calexa
calexa    | Traceback (most recent call last):
calexa    |   File "./src/calexa.py", line 13, in <module>
calexa    |     from flask import Flask
calexa    |   File "/usr/local/lib/python3.6/site-packages/flask/__init__.py", line 7, in <module>
calexa    |     from .app import Flask as Flask
calexa    |   File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 19, in <module>
calexa    |     from werkzeug.local import ContextVar
calexa    | ImportError: cannot import name 'ContextVar'

Could you have a look what is wrong with the container @polcape ?

Did you get it to work @gstlouisgit?

Any help would be appreciated. Thanks.

//Edit: I googled some more. In https://github.com/pallets/flask/issues/4015 it is recommended to increase version of Werkzeuge to >2. If I do that I get a different error:

calexa    | Traceback (most recent call last):
calexa    |   File "./src/calexa.py", line 14, in <module>
calexa    |     from flask_ask import Ask, statement
calexa    |   File "/usr/local/lib/python3.6/site-packages/flask_ask/__init__.py", line 9, in <module>
calexa    |     from .core import (
calexa    |   File "/usr/local/lib/python3.6/site-packages/flask_ask/core.py", line 10, in <module>
calexa    |     from werkzeug.contrib.cache import SimpleCache
calexa    | ModuleNotFoundError: No module named 'werkzeug.contrib'

It seeems flask currently is completely broken... it's sad that you did not publish your container... :-(

Ok, after fidling a bit, it now works with falsk<2 requirement. Not sure I like that...