AWS IoT Button: Send POST request to Google Firebase

AWS IoT Button was introduced by Amazon as the developer version of it’s dash button.

The AWS IoT Button allows user to associate with an AWS Lambda instance to run some code snippet while press the button – either play with other AWS service such as Amazon SNS or integrate with your own service.

The button press has 3 types: single, double and long which can be found from the Lambda event.

Here is a simple code gist to demonstrate sending a POST request to Google Firebase client while the button is pressed:

(Keep in mind that AWS Lambda doesn’t have the npm install for your node.js code function – which means you have to upload a zipped file which contains the node.js node_modules folder as dependency)

'use strict';
* This is a sample AWS Lambda instance with NodeJS
* Simply sending a POST request to Google Firebase
const AWS = require('aws-sdk');
* handler is the entry point of the button click
exports.handler = (event, context, callback) => {
console.log('Received event:', event.clickType);
var request = require('request');
// Firebase auth key
var serverKey = "Firebase Server Key";
var clientToken= "Client Device Token";
var options = {
url: '',
headers: {
'Authorization': 'key=' + serverKey
json: {
"to": clientToken,
"data": {
deviceId: `${event.serialNumber}`,
deviceName: 'IoT Button',
eventName: 'Click',
value: `${event.clickType}, ${event.batteryVoltage}`
};, function optionalCallback(err, httpResponse, body) {
if (err) {
return callback(err);