Facebook chatbot

Hello,

I’m trying to follow the Facebook chatbot example, but I am facing issues at “Verifying your webhook from facebook” section. I am getting the following error from facebook
Quote
The URL couldn’t be validated. Callback verification failed with the following errors: HTTP Status Code = 502; HTTP Message = Bad Gateway
Unquote
when I enter the get URL. I went to API Gateway and verified that the API is indeed deployed.

Unable to move forward because of this.

Can anyone help? Thanks a lot in advance

RKW

Do you know the details of the error? Please check to use sls logs.

Hello,

Thanks for the response.

This is what I see with the logs

START RequestId: 6f011cb6-c21e-11e6-858f-ffc651c7ddfb Version: $LATEST
END RequestId: 6f011cb6-c21e-11e6-858f-ffc651c7ddfb
REPORT RequestId: 6f011cb6-c21e-11e6-858f-ffc651c7ddfb Duration: 0.46 ms
Billed Duration: 100 ms Memory Size: 1024 MB Max Memory Used: 16 MB

But, when I try to verify the webhook from FB, I get to see this response
The URL couldn’t be validated. Callback verification failed with the following errors: HTTP Status Code = 502; HTTP Message = Bad Gateway

Any suggestions as to what I should do?/look for?

Thanks again for responding.

Hmmmm… It seems that nothing remains in the log.

HTTP Status Code = 502; HTTP Message = Bad Gateway

When is this error returning? Is it when you accessed the API Gateway URL? Can I get a screen shot of the error?

And please give me as follow

  • Contents of the serverless.yml
  • the source code of handler.js

Hi,

Seems like 1 step forward and 2 back. I had deleted the lambda function and APIs last week. I am trying to deploy again. But my deployment itself is failing.

My serverless.yml is as follows:

service: gitaquote

provider:
name: aws
runtime: nodejs4.3
region: us-west-2

functions:
webhook:
handler: handler.webhook

events:
  - http:
      path: webhook
      method: GET
  - http:
      path: webhook
      method: POST

Source code of handler.js is as follows:

‘use strict’;

// Your first function handler
module.exports.webhook = (event, context, callback) => {
if (event.method === ‘GET’) {
// facebook app verification
if (event.query[‘hub.verify_token’] === ‘STRONGXXTOKEN’ && event.query[‘hub.challenge’]) {
return callback(null, parseInt(event.query[‘hub.challenge’]));
} else {
return callback(‘Invalid token’);
}
}
};

I am following this tutorial - https://serverless.com/blog/building-a-facebook-messenger-chatbot-with-serverless/
and unable to attach files since this site is not allowing me to upload files with other than jpg, png option.

thanks

I think Integration:lambda is missing in serverless.yml.

By default, the Framework uses the lambda-proxy method

When you use lambda-proxy method, the Lambda function does not work.
Please write Integration:lambda and try again.

Thanks a lot for help. I am still not getting the API endpoints. See the attached screenshot.

I have added Integration: lambda to the .yml

I think Indentation in serverless.yml is incorrect.
Just tested on my side and succeeded.

My serverless.yml as follow

service: gitaquote

provider:
  name: aws
  runtime: nodejs4.3
  region: us-west-2

functions:
  webhook:
    handler: handler.webhook
    events:
      - http:
          path: webhook
          method: GET
          integration: lambda
      - http:
          path: webhook
          method: POST
          integration: lambda

Hello,

Are there any rules with regards to spaces vs tabs in indentation?

That apart, a new issue now. I am using the same yml that you sent.

I deleted all the buckets manually as well as the lambda functions. I see that you mentioned that this got to do with permissions in another thread, but that can’t be the case!

oh dear! this is turning out to be a long thread!

Are there any rules with regards to spaces vs tabs in indentation?

I don’t know. I use only spaces.

I deleted all the buckets manually as well as the lambda functions.

That is the cause. “Update Stack” failed because manually deleted S3 bucket.
Do you know the CloudFormarion stack operated by Serverless? You should delete the CF Stack on AWS Manangemant console, then retry sls deploy again.

As another method, will execute sls deploy with another stage name or region specified.

1 Like

Hi!

Thanks a lot for your help. I now have a working version deployed on my FB page - https://www.facebook.com/gitainmyhw/ ;

I have just purchased a copy of “AWS lambda in action” - hoping to cover the gaps in knowledge.

The Serverless Framework is a breeze. Looking forward to building and deploying apps in the near future and thanks once again for the help!!

Best,

2 Likes