Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Picking Records with JavaScript and a Button
Search
Gordon Diggs
September 11, 2016
Technology
89
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Picking Records with JavaScript and a Button
Gordon Diggs
September 11, 2016
More Decks by Gordon Diggs
See All by Gordon Diggs
John Coltrane: Lessons in Leadership
gordondiggs
2
310
The Customer Gap
gordondiggs
1
120
Kafka Partitioning Algorithm
gordondiggs
0
160
Supbutton
gordondiggs
0
96
Rayons
gordondiggs
0
100
Sous Vide
gordondiggs
0
120
Dev Events & Internal Tools at Paperless Post
gordondiggs
0
130
The Joys and Pains of Working With an Old Codebase
gordondiggs
0
160
The Joys and Pains of Working with an Old Codebase
gordondiggs
1
2.4k
Other Decks in Technology
See All in Technology
Data + AI Summit 2026 イベントレポート: 「AIがビジネスで意思決定するデータ基盤」へ
nek0128
0
280
オブザーバビリティ、本当に活用できてる? 〜API連携×生成AIで成熟度を自動評価〜
dmmsre
1
3.6k
発表と総括 / Presentations and Summary
ks91
PRO
0
140
Playwright × AI Agent でE2Eテストはどう変わるか AI駆動テストの可能性と実用検証の結果
taiga7543
1
350
穢れた技術選定について
watany
17
5.6k
Oracle Exadata Database Service on Cloud@Customer X11M (ExaDB-C@C) サービス概要
oracle4engineer
PRO
2
8.4k
Compose 新機能総まとめ / What's New in Jetpack Compose
yanzm
0
320
Amazon EVS で VCF 9.0 / 9.1 のサポート開始まとめ
mtoyoda
0
310
知らん間に、回ってる
ming_ayami
0
730
AICoEでAIネイティブ組織への進化
yukiogawa
0
200
人を動かすのは時間ではなく、納得感 〜新任EMが入社3ヶ月、組織を2回変えた話〜
kakehashi
PRO
3
270
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
15
110k
Featured
See All Featured
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
390
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
530
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Designing Powerful Visuals for Engaging Learning
tmiket
1
450
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.5k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
260
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
260
Testing 201, or: Great Expectations
jmmastey
46
8.2k
Building AI with AI
inesmontani
PRO
1
1.1k
Transcript
Picking Records with JavaScript and a Button ManhattanJS 20160914
Picking Records with JavaScript and a Button ManhattanJS 20160914
@GordonDiggs
None
None
None
None
None
Lambda Example Sources • S3 file created or deleted •
SNS event • Updates to a DynamoDB table
None
None
None
Requirements • Get a random record • Send a text
message with that record’s information
const env = require("node-env-file"); env(`${__dirname}/.env`); process.env.NODE_CONFIG_DIR = "/var/task/config"; const twilio
= require("twilio")(process.env.ACCOUNT_SID, process.env.AUTH_TOKEN) , getJSON = require("get-json"); const getRecord = function(callback) { getJSON("https://rayons.info/items/random.json", function(err, item) { if (err) { console.log("got an error: ", err); callback(null); } else { const itemURL = `https://rayons.info/items/${item.id}`; callback(`You should listen to "${item.title}" by ${item.artist}: ${itemURL}`); } }); }; const sendSMS = function(message, callback) { twilio.sendMessage( { body: message, from: process.env.FROM_NUMBER, to: process.env.TO_NUMBER }, function(err, responseData) { console.log("Twilio response:", responseData); if (err) { callback("API request completed with error(s)."); } else { callback("API request sent successfully."); } } ); }; exports.handler = function (event, context) { getRecord(function(message) { if (message) { sendSMS(message, function(status) { context.done(null, status); }); } else { context.done(); } }); };
const env = require("node-env-file"); env(`${__dirname}/.env`); process.env.NODE_CONFIG_DIR = "/var/task/config"; const twilio
= require("twilio")(process.env.ACCOUNT_SID, process.env.AUTH_TOKEN) , getJSON = require("get-json");
const getRecord = function(callback) { getJSON("https://rayons.info/items/random.json", function(err, item) { if
(err) { console.log("got an error: ", err); callback(null); } else { const itemURL = `https://rayons.info/items/${item.id}`; callback(`You should listen to "${item.title}" by ${item.artist}: ${itemURL}`); } }); };
const sendSMS = function(message, callback) { twilio.sendMessage( { body: message,
from: process.env.FROM_NUMBER, to: process.env.TO_NUMBER }, function(err, responseData) { console.log("Twilio response:", responseData); if (err) { callback("API request completed with error(s)."); } else { callback("API request sent successfully."); } } ); };
exports.handler = function (event, context) { getRecord(function(message) { if (message)
{ sendSMS(message, function(status) { context.done(null, status); }); } else { context.done(); } }); };
None
Thank you! • github.com/GordonDiggs/what_should_i_listen_to_lambda • aws.amazon.com/lambda • twitter.com/GordonDiggs • bitly.com/gd-lambda