AWS Lex and Facebook Messenger Integration Not Working - amazon-web-services

I'm banging my head against the wall trying to get an AWS Lex based chatbot integrated with Facebook.
As far as I can tell, everything is set up correctly.
When I send a message to my page in Facebook, I don't get a reply. However, the analytics in my app shows that the app is getting messages, so I know the message is making it from the page to the app.
When I try to hit the AWS Lex Webhook directly using POSTMAN, the webhook responds to literally everything I sent to it with a blank HTTP 200 OK response.
The lambda function that is tied to the AWS Lex chatbot is not getting invoked as a result of the messages from Facebook because no logs are getting generated and cloudwatch doesn't show an attempts to run the lambda function.
Does anyone have any ideas?
UPDATE : I ended up engineering around this by bypassing the Facebook channel capability inside AWS Lex and using Lambda instead. I deployed a passthrough API which calls a lambda function and then interacts with AWS Lex via Boto3/Python. In theory this is all supposed to be taken care of from inside AWS Lex with the Facebook channel integration, but I wasn't able to get it to work so I just built around it.

Verify Amazon lex is properly configured with facebook messenger .
Check : Page access token
Verification token
App ID
Check if your webhook is subscribed to page you are messaging on.
Check if your facebook user is added as tester/admin/developer
Check if your latest version of BOt is published on intended alias.
Also while configuring webhook tick necessary options : messages, messaging_postbacks, messaging_optins, message_deliveries, message_reads, messaging_payments
This should resolve your head ache. If not please reply

Related

Why unsubscribed Application token can be used to access WSO2 APIM endpoint?

There is an API hosted in WSO2 APIM 4.1.0 and there are two different App subscribed to that API.
Before Unsubscribe:
I just unsubscribed one of App to delete the API subscription by follows wso2 doc
After Unsubscribe:
After unsubscribed , I can able to invoke WSO2 API by using unsubscribed Application token
It should now allow that unsubscribed app to invoke API. OR correct me if my understanding is wrong.
Postman :
Note: In above API Hit, I passed unsubscribed APP token as Authorization
In your case, you should not be able to invoke the API without a proper subscriptions. Although the token is valid, you should get a 403 HTTP code saying subscription validation has failed.
You can check whether the events are propagated successfully to your gateway node from the control plane node. This is basically when you have a distributed setup. If you have a HA setup, verify both nodes are working properly when it comes to event distribution.
Are you using the GA release of APIM 4.1.0? If so, this could be a bug in that was fixed later through U2 updates. When an application subscription is deleted, any API invocations done using the tokens of that application should fail due subscription validation with an error similar to the one below with a 403 HTTP code.
{"code":"900908","message":"Resource forbidden ","description":"User is NOT authorized to access the Resource. API Subscription validation failed."}
If you have a paid WSO2 subsciption, please try this scenario by taking the latest U2 updated/patched version of APIM 4.1.0 by referring this.
I tried the GA APIM 4.1.0 and this usecase worked as expected. Shall we verify the subscription delete event flow in the API gateway by enabling debug logs for gateway and keymanagement components?
Add the following configurations in the <APIM_HOME>/repository/logs/log4j2.properties
logger.gateway-component.name = org.wso2.carbon.apimgt.gateway
logger.gateway-component.level = DEBUG
logger.keymgt-component.name = org.wso2.carbon.apimgt.keymgt
logger.keymgt-component.level = DEBUG
make sure to add the newly created loggers as below.
loggers = gateway-component,keymgt-component, AUDIT_LOG, trace-messages, org-apache-coyote, ....
With these, subscribe and unsubscribe events should be displayed in the terminal. You can use them to verify the event flow.

Instagram API Webhook URL not receiving test updates

I have a Business App in dev mode and would like to test the handling of a test updates to my webhook for Instagam, but none of my test updates seem to go through.
I'm trying to use a Firebase HTTP Cloud Function to handle the verification and notification updates. Upon setting up the HTTP cloud function to respond appropriately if it's invoked with a GET or a POST request, I deployed my function to Firebase Cloud Functions.
I followed the steps in the getting started pages of using Webhooks, including configuring the Webhook Product, enabling page subscriptions, I have access to the Instagram Account and Facebook Page with admin access, but none of my test updates are going through to the webhook url, which I specified as a url to my Firebase Cloud Function.
My firebase cloud function url is
https://us-xxxx-xxxx-xxxxx.cloudfunctions.net/webhooks with the "xxxx" covering my project id details. When I first specify my url Webhook URL using "Instagram" and subscribing to "messages" I see that my function get's one GET request, but that's it. No test updates, or subscribing updates go through.
What the function currently does is respond with the hub.challenge if the request to the cloud function is a GET request, and if it's a POST request to the cloud function, I'll send 200 OK HTTPS. I have print messages along the way so I would know in my cloud function logs that something is being triggered. Any ideas?
Any suggestions on what to do to get the test webhooks to show up would be great. Thanks

DialogFlow, modify user request

for my dialogflow project I would like to intercept the user request before the dialogflow responds with the appropriated intent.
My goal:
-The user sends a request with an input message
-I access this message, I transform it (I apply a function to it) and then it is delivered to the dialogflow (so dialog.
I'm using a webhook linked to an specific intent. I'm using cloud functions to handle the webhook.
I would like to access the request using this webhook, modify the original request and allow dialogflow to respond according to this new modified request.
I hope I've made myself clear.
Thank you very much in advance!
I think it is not possible using a webhook, I suggest you to take a look at the Dialogflow fulfillment documentation. As you can see in the architecture representation, your webhook is behind of the intent matched, so the user request has been processed by Dialogflow and the fulfillment will perform actions based on the matched intent, so you only be able to modify the task on the service that you defined within the fulfillment and its response.
You could be able to do this according to your use-case, if you're using a custom development to make calls to the Dialogflow API, you can add an additional step between End-User and Dialogflow where you could intercept the user request, modify it and then send it to the Dialogflow API.
If you’re using any integrations such as Action on Google or Dialogflow Hangouts, this will not be possible since these services are the ones that manage the calls to the Dialogflow API.

SurveyMonkey - Create Webhook with AWS API Gateway as Subscription Url

I am trying to Integrate SurveyMonkey with my backend.
This is the flow:
(1) We create a webhook(https://developer.surveymonkey.com/api/v3/#webhooks) using POST method from PHP, with Subscription url as an AWS API Gateway.
(2) When user completes a survey, SurveyMonkey invokes the subscription Url (API Gateway), which in turn calls a Lambda function to update the database.
The problem is when i try to give a API Gateway url as the subscription Url, SurveyMonkey returns a Bad Request response. If i use a general .php page, the webhook is getting created successfully.
In the conversation with SurveyMonkey Support Team, they say, the API Gateway should return a 200 response for HEAD request. I am not sure how to set this up in AWS.
Can anyone who has implemented / integrated, API Gateway with SurveyMonkey please guide me on how to solve this issue?
Here is the conversation with SurveyMonkey Support Team:
Thanks for getting back in touch. I just spoke with my colleagues on
the development team and they noted that there shouldn't be an issue
in using a lamda function for your subscription_URL. As long as it
accepts HEAD and POST requests and returns a 200. I hope this helps
you out; of course, please let me know if I can assist further.
Thanks for getting back in touch. I wanted to confirm that the lambda
function needs to return a 200 to a HEAD request in order for us to
enable the webhook properly. This isn't done after the webhook is
cerated, but as the webhook is created. It still seems like the
lambda function isn't responding, or responding correctly, as it is
created, so it will continue to fail. I hope this helps clarify;
please let me know if I can assist further.
One way or another, you need to get the API Gateway to respond to HEAD requests. There are a lot of ways to do this. You could add a HEAD method to the resource of your URL. You can do that in the API Gateway console under the resource section when you're editing you api. You can send the HEAD requests to a lambda function and have that function return a 200 status code for appropriate HEAD requests. You can set up a mock return in the api integration request, but you'll need to set up the correct integration details. You can also just set ANY lambda proxy integration and deal with everything on the lambda side.
Once you have something setup you should be able to test with curl:
curl -I http://yourUrl.example.com

Facebook webhook does not trigger via native app

I have configured the Facebook Webhook of my app, that it sends a call when a change has happened on my (user)feed. When I post something on Facebook via my laptop or mobile browser, the Webhook triggers.
But when I post something via the native iOS app, it doesn't trigger.
Does anyone have an idea about this?