AWS Serverless Framework Nodejs Push Notification - node.js

I am using Serverless framework to create lambda functions with node.js backend that uses fcm-push package.
Desired flow :
Call api from mobile app -> api uses fcm-push package to send the payload/message/registration tokens to Firebase Cloud Messsaging -> sends push notification to Android and iOS devices
This works perfectly when I run the api locally using "serverless invoke local..."
However, when I do "serverless deploy" and hit the api endpoint from mobile app OR a rest client like Postman, the api call times out, i changed the timeout to 45 seconds and still times out. To troubleshoot, I removed all fcm related code from the api to see if api returns a response while hitting from mobile app/Postman. It does. So it seems like AWS is preventing the api to make a call to fcm, and the call lasts until it times out.
I am not sure what I can do to get around this as I am fairly new to using AWS, so any input would be helpful

If you are using API Gateway as API endpoint which is connected to a lambda function, then you need to specify the body template in the API gateway itself. Make sure you are able to get the values at your Lambda function that you have been sending via the REST API call to your API gateway.
Please find the link to this answer I wrote earlier to achieve the same.

You should check for any break point in your function.

Related

Communicate two ionic - angular apps through node server

I have two Ionic applications, and both use the same API served with node. What I need is that when one app sends a post request, the other app gets that post request and uses the information that comes from the request. How can I achieve this? I thought of listening for that particular post request, but I don't know if that's possible, or when the post request reaches the API, trigger some action in the server that sends the information to the other app. Is this possible?
You can use Firebase Cloud Messaging to implement this.
When one ionic application requests a service from your server by using HTTP Requests, the server will trigger the respective action and sends a push notification to your other app by using the Firebase cloud messaging service. Your 2nd app will capture this push notification by subscribing to a URL in Firebase.
For the server-side, You can use fcm-node module or Firebase NodeJS Module to implement this functionality. For the mobile app, you can use providers in ionic to subscribe to firebase cloud messages
A detailed guide on implementing push notifications can be found here

How to get data from Secure REST API in lambda for Alexa skill?

I am creating a Alexa Skill that will get data from BPM tool.
My BPM Tool provide a secure rest api that we can invoke with basic auth like username and password.
How can i call this type of web api in node.js code created in lambda?
Steps:
1) Create Amazon API Gateway api for alexa and deploy into stage
2) Write lambda to work with Alexa Skill
3) Call your API end poingt into your node.js
https://github.com/alexa
https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs
If you are worried about credentials, you can set those up as environment variables for your lambda.
With that out of the way, you should be able to use any http library (like axios or needle) to make the requests to the service.

Azure Bot service talking to Azure Logic App - 401 unauthorized

I have an Azure bot which is all developed and working fine. It currently talks to a 3rd party workflow application via a simple webhook.
I am now trying to replicate this using Azure Logic App. I have a simple logic app that responds fine to requests from POSTMAN. However, when I set the Messaging Endpoint in the Azure Bot service to the URL of the logic app's top node (when a http request is received), I see 401 unauthorized responses from all of my channels in the bot and I don't know why. POSTMAN is using the exact same target URL and works fine.
Any ideas what is going on here?
I had a similar problem, and found the solution was to first ensure an Authorization header is being sent, and 2nd, set the value to null.
Refer: https://learn.microsoft.com/en-us/outlook/actionable-messages/security-requirements#action-authorization-header

Built in Azure Iot-Hub endpoints

I'm using IoTHub F1 subscription and facing following problem:
I'm calling REST endpoint for get device list from iothub,
Ex: https://my_iothub_name.azure-devices.net/devices?top=10&api-version=2016-11-14
The above api call is working fine from postman (postman is ApiAgent)
But the problem is when I'm calling same api from browser it's giving me 405 method not allowed error.
I've read about it and it's looks like problem with OPTIONS request from browsers.
Please throw some lights on this issue,
Thank you very much.
I don't think this is currently possible, first because, from what I see, Azure IoT hub REST API does not issue CORS requests (i.e. they don't write in the CORS header access-control-allow-origin), so your browser client can't access it.

How to make authentication REST API calls to Azure App service (Api App)

Is there a way to test my App service api app & Authentication using tool such as Fiddler? I used to be able to do this for Mobile Service by passing the token in the request header (x-zumo-auth). But now with App Service, it's no longer working or available.
Reason I ask is that my client won't be limited to those platform or will they be developed using those languages/SDK so I need a way to make REST API calls.
I am not sure about Fiddler, but I have used the Google Chrome Postman extension to do this kind of thing before and it works really well. It is free and you can get it from here (you'll need chrome installed): https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop

Resources