Amazon Echo Hello World with PHP endpoint

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

  1. Avinash

    Avinash New Member

    Messages:
    19
    Likes Received:
    1
    Trophy Points:
    3
    Not only the reason for not using Node.js. Because my application may have lot of api requests. Totally new to AWS!
     
  2. Chad Doebelin

    Chad Doebelin New Member

    Messages:
    17
    Likes Received:
    3
    Trophy Points:
    3
    Gender:
    Male
    You just have to wait it out, I signed up in around Feb 28th and they just sent me an email like 2 days ago saying that they had accepted me.

    So are you even able access the menus to setup the endpoints in your developer console yet?
     
  3. Avinash

    Avinash New Member

    Messages:
    19
    Likes Received:
    1
    Trophy Points:
    3
    You are saying about alexa section of developer console right where we register our app. In registration process we have SSL Certificate section where we have three options.
    From those three I have used 2nd[My development endpoint is a subdomain of a domain that has a wildcard certificate from a certificate authority] & 3rd[I will upload a self-signed certificate in X.509 format.]. I it didn't worked.

    And in the app info section I have included my endpoint. Hope you said abt this only?
     
  4. Jeff C

    Jeff C Administrator Staff Member

    Messages:
    77
    Likes Received:
    4
    Trophy Points:
    8
    Hmm I didn't use the wildcard in mine, here is what I have:
    Capture.JPG

    If you want to see my sample output (you have to accept the self signed cert):

    https://www.echoforum.com/echotest
     
  5. Avinash

    Avinash New Member

    Messages:
    19
    Likes Received:
    1
    Trophy Points:
    3
    Yeah I used third option as well. Same thing I did! You are using same code right you mentioned at the topmost post(PHP code).

    But when I attempting to open [https://www.echoforum.com/echotest] it asked me for certificate which is right! But After accepting certificate it show's me Invalid Request.
    Is that right response that I am getting in your endpoint?
     
  6. Jeff C

    Jeff C Administrator Staff Member

    Messages:
    77
    Likes Received:
    4
    Trophy Points:
    8
    In the post above you said you used the second option? It should say Invalid Request because you are not Amazon.com. :)
     
  7. Avinash

    Avinash New Member

    Messages:
    19
    Likes Received:
    1
    Trophy Points:
    3
    Yes Jeff I actually use both options 2nd as well as 3rd. When I request my endpoint it returns json and when I hit your endpoint it says Invalid Request!

    Can I know why this difference in our endpoints? Can you provide me sample code of yours? Or you are using same code you published in the thread?
     
  8. Avinash

    Avinash New Member

    Messages:
    19
    Likes Received:
    1
    Trophy Points:
    3
    Also I am not getting my SSL Certificate Option Green Tick?
    What about yours? alexa_ssl.jpg
     
  9. Chad Doebelin

    Chad Doebelin New Member

    Messages:
    17
    Likes Received:
    3
    Trophy Points:
    3
    Gender:
    Male
    I understand you are trying to use your own host, but you did ask about Lambda as well. These are the steps that I follow to create a new app using Lambda.


    To get the Lambda to work, you need to select option 1 "My development endpoint has a cert from a TA" on the method.

    Then in the AWS Lambda console, you need to ensure that you are using an east coast lambda server (N. Virginia) in the upper right hand corner

    Create your new lambda function as normal.

    After you create the function, you need to be on the function list, have your function selected and hit the Actions button and select "Add an Event Source"

    change the event source type from S3 to Alexa App Kit

    then hit submit, then copy the Function ARN arn:aws:lambda:us-east-1:xxxxxxxx and paste that into your Amazon developer console app endpoint box.
     
  10. Avinash

    Avinash New Member

    Messages:
    19
    Likes Received:
    1
    Trophy Points:
    3
    Thanks Buddy!

    Finally I have started with AWS Lamda and got some questions around me,
    1. How can I make API calls on aws lamda using node.js? if yes then how I can do that? I used 'request' module to make a requests to my api's but it didn't worked and said
    "errorMessage": "Cannot find module 'request'"
    Any other options on this?

    2. Can I get location of my echo device?

    3. If I hit too many api calls will it affect performance of my lambda function? if yes then at which extinct?
    .
     
    Chad Doebelin likes this.
  11. Chad Doebelin

    Chad Doebelin New Member

    Messages:
    17
    Likes Received:
    3
    Trophy Points:
    3
    Gender:
    Male

    1.)
    the requests module is not available with barebones lambda, there is a way to use grunt to add node packages and upload a .zip to AWS to use with your lambda functions, but it's kinda complicated and i havent successfully accomplished that yet.
    but you can use the
    http = require('http');
    or
    https = require('https);

    here is the source code for an app that I made to spot check the price of bitcoin it uses http.get to pull json and parses it and does speech output
    http://hastebin.com/ezosemetiq.js

    2. )
    I didnt see any location stuff in the documentation, seems like the only thing we can do is tell her what speech to output.

    3.)
    I don't know how to answer that question.
     
  12. Chad Doebelin

    Chad Doebelin New Member

    Messages:
    17
    Likes Received:
    3
    Trophy Points:
    3
    Gender:
    Male
  13. Chad Doebelin

    Chad Doebelin New Member

    Messages:
    17
    Likes Received:
    3
    Trophy Points:
    3
    Gender:
    Male
    and one other bit of advice about lambda functions and node.js that i battled with for fucking ever.
    everything is synchronous.
    so if you make a http.get call it will execute at the same time as your logic for parsing the data you requested.
    even something as simple as a for loop, there is no guaranteed order of looping, all loops execute at the same time.
    I have been using setTimeout(function,100);
    to set delays, but that's not really how you're supposed to do it.
    you need to make your applications event driven rather than sequential instructions.

    I don't really understand how to use this invokeasync option so if anyone else figures it out let me know how to do it.
    http://docs.aws.amazon.com/lambda/latest/dg/API_InvokeAsync.html
     
  14. Avinash

    Avinash New Member

    Messages:
    19
    Likes Received:
    1
    Trophy Points:
    3
    Hi there,
    I checked sample color application for Alexa which works perfectly. Then I created my own lambda function with my own code.
    Intents in sample app:
    {
    "intents": [
    {
    "intent": "MyColorIsIntent",
    "slots": [
    {
    "name": "Color",
    "type": "LITERAL"
    }
    ]
    },
    {
    "intent": "WhatsMyColorIntent",
    "slots": []
    }
    ]
    }

    Utterances In sample app:
    MyColorIsIntent my color is {dark brown|Color}
    MyColorIsIntent my color is {green|Color}
    WhatsMyColorIntent whats my color
    WhatsMyColorIntent what is my color

    In app registration console, I pasted my own Intent's and Slots. So when I use these slots in my code I'm getting like 'undefined' for my slots.
    I am not getting input values provided to my slot. Means I am using 'City' slot in place of 'Color' slot.
    I don't know where I am doing wrong here? Is there any other place where we define our Intents and slots?

    Note: But intents are working fine If I don't use slots.
     
    Last edited: Jun 18, 2015
  15. Avinash

    Avinash New Member

    Messages:
    19
    Likes Received:
    1
    Trophy Points:
    3
    Even when I registered my app with my own slots,
    - If I use my slot like 'City' it isn't working.
    - If I use 'Color' slot in the code it works, even though in my registration console I am using my own slots like 'City' slot

    Here my Intents:
    {
    "intents": [
    {
    "intent": "MyColorIsIntent",
    "slots": [
    {
    "name": "City",
    "type": "LITERAL"
    }
    ]
    },
    {
    "intent": "WhatsMyColorIntent",
    "slots": []
    }
    ]
    }
    Utterances :
    MyColorIsIntent my city is {dark brown|City}
    MyColorIsIntent my city is {green|City}
    MyColorIsIntent my favorite city is {red|City}
    MyColorIsIntent my favorite city is {navy blue|City}
    WhatsMyColorIntent whats my city
    WhatsMyColorIntent what is my city
    WhatsMyColorIntent say my city
    WhatsMyColorIntent tell me my city
    WhatsMyColorIntent whats my favorite city
    WhatsMyColorIntent what is my favorite city
    WhatsMyColorIntent say my favorite city
    WhatsMyColorIntent tell me my favorite city
    WhatsMyColorIntent tell me what my favorite city is
     
  16. Avinash

    Avinash New Member

    Messages:
    19
    Likes Received:
    1
    Trophy Points:
    3
    Do I need to upload my Intents & Utterances file at lambda console? If yes then how? and with which extensions?
    Error I got:
    favoriteColorSlot.value: undefined
     
  17. iWombat

    iWombat New Member

    Messages:
    6
    Likes Received:
    2
    Trophy Points:
    3
    Gender:
    Male
    I am at the same place.
    Having changed my lambda function in the console to use new intent values, I need to
    change the intents such as "MyClolorIsIntent", but I can't see where to do it in the lambda console.

    Anyone figure this out?
     
  18. iWombat

    iWombat New Member

    Messages:
    6
    Likes Received:
    2
    Trophy Points:
    3
    Gender:
    Male
    Alternately, has anyone figured out the proper zip file structure to upload to the console (which presumably can include the new intents)?
     
    Avinash likes this.
  19. Avinash

    Avinash New Member

    Messages:
    19
    Likes Received:
    1
    Trophy Points:
    3
    Hi Guys, I'm still confused about the Intents & Utterances. Where can I update these things?

    'AS I SAID THESE ISSUE'S WAS FOUND WHILE DEVELOPING IN node.js BUT SAME ISSUE I GOT WHILE DEVELOPING WITH php '

    Below issue when developing with php:

    Here is my one of Utterance like MyCityIntent my city is {New York|UserCity}
    When I say to echo 'my is New york' it gives me response. But When I say some other words like 'San Francisco' it doesn't take. I don't know why? According to docs it should take more than few words with a slot of type LITERAL.
    If I change my slot name to something other like below:
    MyCityIntent my city is {abc xyz|UserCity}
    After updating this, when I say New York. In response, it just take xyz instead New York. I don't know why this happening and how to resolve this??

    Please guy's tell me the solution on this. I am trying in both node.js & php as well but getting same issues regarding intents & utterances.

    Here is what they said on docs with below example:
    StatusUpdate post the update {arrived|UpdateText}
    StatusUpdate post the update {dinner time|UpdateText}
    StatusUpdate post the update {out at lunch|UpdateText}

    StatusUpdate post the update {going to stop by the grocery store this evening|UpdateText}
    This includes sample slot values ranging from one word (“arrived”) to about ten words. This type of sample coverage should provide better recognition.
     
  20. iWombat

    iWombat New Member

    Messages:
    6
    Likes Received:
    2
    Trophy Points:
    3
    Gender:
    Male
    Are you updating your code via the AWS Lambda Console screen editor, or uploading it via a zip file?

    It seems as though the screen editor in the console uses a pre-defined set of utterance and intent definitions gathered from the examples.
    I thought I could get around this by uploading the code via a zip file that included both inline intents or intents defined in a json file added to the zip but I have not gotten this to work yet. I would like to see a working AWS Echo app Lambda zip file as an example, but while you can upload a zip, console won't let you download one, so there is no way to interrogate the provided console examples.
     

Share This Page