dialogflow / dialogflow-nodejs-client

Node.js SDK for Dialogflow
Apache License 2.0
659 stars 287 forks source link

ServerError: Wrong response status code. #58

Open prakharter opened 7 years ago

prakharter commented 7 years ago

Hi ,

I have created several Intents but for some of them when i am using the NodeJS SDK the response is coming on error inside the below code with the error as ServerError: Wrong response status code.

request.on('error', function(error) { console.log(error); }); This works find from the api.ai test console. Please advise

prakharter commented 7 years ago

Any suggestions please ?

jacksun101 commented 7 years ago

I got this issue too.

robwhelan commented 7 years ago

Same here

codinsonn commented 7 years ago

I encountered this error while forming my apiaiRequest, and I was so convinced this wasn't it at first, but it seems I was using the entire 'message' node instead of 'message.text', resulting in an object being passed down with stuff like $mid and such in it.

Haven't encountered the error anymore since switching to just text being passed into the apiaiRequest as the first argument. Though, in other people's cases, it could be something else.

juliusspencer commented 7 years ago

I am trying to get Alexa to use AWS Lambda which is set up using AlexaApiAiBridge and I'm also having the same issue. I have narrowed it down to the request's sessionId. If my sessionId is sent through as:

"sessionId": "amzn1.echo-api.session.[unique-value-here]",

it works fine, but if I use a real one:

"sessionId": "SessionId.fe89ec31-638c-45f4-80b9-e71456539a32",

I get the response error:

ServerError: Wrong response status code.

I'm stuck on this so any help would be greatly appreciated.

sstepashka commented 7 years ago

@juliusspencer https://docs.api.ai/docs/query#query-parameters-and-json-fields

A string token up to 36 symbols long, used to identify the client and to manage session parameters (including contexts) per client.

juliusspencer commented 7 years ago

@sstepashka Thanks for the quick response. Does this mean API.AI won't support Alexa requests? Maybe there needs to be some session management in AlexaApiAiBridge.

I'm new to Alexa (I've been using a Google Home so far).

sstepashka commented 7 years ago

@juliusspencer Please, red this line https://github.com/Gnzlt/AlexaApiAiBridge/blob/master/index.js#L104 The developer just cutoff part of ID, if your replace this code for the following:

alexaSessionId = sessionId.split('SessionId.').pop();

We don't support 'AlexaApiAiBridge'. It is third party.

juliusspencer commented 7 years ago

Oh right, that makes a lot of sense, I will try this.

Thank you so much! Hopefully someone will find this useful. I will try create a PR.

patcat commented 7 years ago

I've made a pull request on their repo that uses partially this solution and partially a different one to make up for the two different session id formats that Amazon uses :)

thierryskoda commented 7 years ago

Anyone still has that error? Been using this SDK for 8 months now without any problems and now suddenly it doesn't work...

I have the simplest test every and still receives the same error. ServerError: Wrong response status code.

apiaiService
    .textRequest('test', { sessionId: shortid.generate() })
    .on('response', console.log)
    .on('error', err => {
        console.log("err", err)
    })
    .end()

Thank you for any help!