Amazon Echo Hello World with PHP endpoint

Discussion in 'Amazon Echo Development' started by Jeff C, Apr 21, 2015.

  1. Jeff C

    Jeff C Administrator Staff Member

    Messages:
    77
    Likes Received:
    4
    Trophy Points:
    8
    For the simplest method to return a "Hello World!" response when developing your Echo app, create a PHP file named echo.php with the following contents:

    Code:
    <?php
    
    $data = file_get_contents("php://input");
    
    header('Content-Type: application/json;charset=UTF-8');
    
    $text = '{
        "version" : "1.0",
        "response" : {
            "outputSpeech" : {
                "type" : "PlainText",
                "text" : "Hello World!"
            },
            "shouldEndSession" : false
        }
    }';
    
    header('Content-Length: ' . strlen($text));
    
    echo $text;
    Then define your intent schema with the following:

    Code:
    {
        "intents": [
            {
            "intent": "test",
            "slots": [
       
            ]
            }
        ]
    }
    With the following sample utterance:

    Code:
    test hello
    Just point your enpoint to the echo.php script and you should be able to say:

    Alexa launch [Spoken Name]

    Alexa test hello

    If all goes well, it should provide you with a response. Here is exactly how the response should be sent to Amazon in the response (note, I am using a self signed SSL cert that you will have to accept in order to see):

    https://www.echoforum.com/helloworld/
     
    Avinash likes this.
  2. Chad Doebelin

    Chad Doebelin New Member

    Messages:
    17
    Likes Received:
    3
    Trophy Points:
    3
    Gender:
    Male
    i haven't received the sdk yet, but my echo arrived today. i am itching to dig into this thing, what do you mean by "point your endpoint"
     
  3. Jeff C

    Jeff C Administrator Staff Member

    Messages:
    77
    Likes Received:
    4
    Trophy Points:
    8
    When you design a new app, you have to define where on the web your app will communicate. So if you say "Alexa, test hello", it will send that data to the URL you define as your endpoint.
     
  4. Chad Doebelin

    Chad Doebelin New Member

    Messages:
    17
    Likes Received:
    3
    Trophy Points:
    3
    Gender:
    Male
    can this be done without the sdk? are they providing an IDE?
     
  5. Jeff C

    Jeff C Administrator Staff Member

    Messages:
    77
    Likes Received:
    4
    Trophy Points:
    8
    Yeah, you don't need any SDK or IDE, you just have to register your app, give sample utterances, provide either a real or self signed cert (for testing) and an endpoint.
     
  6. Chad Doebelin

    Chad Doebelin New Member

    Messages:
    17
    Likes Received:
    3
    Trophy Points:
    3
    Gender:
    Male
    sorry for all the stupid questions.

    are you talking about registering the app at developer.amazon.com?

    http://imgur.com/y2tzXF7

    [​IMG]
     
  7. Jeff C

    Jeff C Administrator Staff Member

    Messages:
    77
    Likes Received:
    4
    Trophy Points:
    8
    They have a special section there at that area where you can do that, yes.
     
  8. Chad Doebelin

    Chad Doebelin New Member

    Messages:
    17
    Likes Received:
    3
    Trophy Points:
    3
    Gender:
    Male
    Well it doesn't seem that the option is available to me yet.
    :(
     
  9. Jeff C

    Jeff C Administrator Staff Member

    Messages:
    77
    Likes Received:
    4
    Trophy Points:
    8
    Did you apply for their SDK?
     
  10. Chad Doebelin

    Chad Doebelin New Member

    Messages:
    17
    Likes Received:
    3
    Trophy Points:
    3
    Gender:
    Male
    Yes, back in February when I first saw they were making it available.
     
  11. heapmaster

    heapmaster New Member

    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    California, USA
    Thanks for that example, I cant wait for the API to be public so I can start writing apps once I get my echo.
     
  12. Avinash

    Avinash New Member

    Messages:
    19
    Likes Received:
    1
    Trophy Points:
    3
    Hi,
    I am developing app for amazon echo device. I have done with my app registration on amazon developer portal as per the instructions.
    I developing app with my webservice(endpoint) for which I am using PHP.

    According to amazon this endpoint must support HTTP over SSL/TLS, So I made my endpoint according to amazon requirements.
    But when I call my app in echo like Alexa, launch MyAppName then in cards it shows like SSL Certificate Verification Failed and saying the message like The certificate does not have a path to the trusted authority. This happens if you are using self-signed certificate.

    The amazon docs says for testing purpose, I can use self signed certificate or my endpoint should be a subdomain of a domain that has a wildcard certificate from a certificate authority. But that doesn't worked for me.
    NOTE: I am using the same PHP code mentioned in this thread.

    Also can I get some more samples in PHP? Screenshot_2015-06-10-18-38-49.jpg
     
  13. Jeff C

    Jeff C Administrator Staff Member

    Messages:
    77
    Likes Received:
    4
    Trophy Points:
    8
    When you created your app in the amazon portal, did you indicate it was a self signed cert?
     
  14. Avinash

    Avinash New Member

    Messages:
    19
    Likes Received:
    1
    Trophy Points:
    3
    I had created my app in the last month, may be after 10th May. And also I selected self signed certificate option for my endpoint.
     
  15. Jeff C

    Jeff C Administrator Staff Member

    Messages:
    77
    Likes Received:
    4
    Trophy Points:
    8
    Did you add your cert to the amazon control panel?
     
  16. Avinash

    Avinash New Member

    Messages:
    19
    Likes Received:
    1
    Trophy Points:
    3
    Yes. I did created my self signed certificate as per instruction and pasted into amazon control panel.
    I am using this option for self signed certificate from mention 3 options: "I will upload a self-signed certificate in X.509 format."

    I used 2nd option as well [My development endpoint is a subdomain of a domain that has a wildcard certificate from a certificate authority] but it didn't worked.
     
  17. Jeff C

    Jeff C Administrator Staff Member

    Messages:
    77
    Likes Received:
    4
    Trophy Points:
    8
    Hmm, SSL is not my strongpoint. What happens when you try to query the endpoint yourself? Do you get any SSL errors (besides it being self signed)?
     
  18. Avinash

    Avinash New Member

    Messages:
    19
    Likes Received:
    1
    Trophy Points:
    3
    When I request my endpoint it simply gives me response in json as written in code. Can I know which method you are using for your endpoint?
    Because you know I don't know what exactly I am missing here? Do you have any other option for me regarding this endpoint. About code I using your code for testing connection with echo.

    Do you have any other resources so that I can go through?
    In the docs it says wildcard certificate with trusted authority(amazon trusted certified) the endpoint should be! How can I do that?

    Anything on AWS Lambda? If you know?
     
  19. Chad Doebelin

    Chad Doebelin New Member

    Messages:
    17
    Likes Received:
    3
    Trophy Points:
    3
    Gender:
    Male
    I finally got my links to the SDK. I am using Lambda right now. First time using node.js. Avinash, are you having trouble getting lambda to work? I might be able to help.
     
    Avinash likes this.
  20. Avinash

    Avinash New Member

    Messages:
    19
    Likes Received:
    1
    Trophy Points:
    3
    No currently I am not using AWS Lambda as I never worked on node.js. How did you got those links to SDK? I'm also registered for SDK but didn't got anything!
     

Share This Page