AWS Lambda Skill Handler returns before database Get is completeAWS Lambda “Process exited before completing request”Alexa Skills Kit Lambda Region IssueLambda Alex Skill session attribute is undefinedCan Lambda Invoke An Alexa Skill?Error in Lambda Handler for Alexa Skill using PythonAWS Lambda 'Process exited before completing request'Use Lambda code for an Alexa skillLambda function ends before DynamoDB get ends in Alexa skillScanning DynamoDB table not showing results from the column specified in ProjectionExpressionUnable to properly retrieve read JSON data from DynamoDB database for Alexa skill
Did "Dirty Harry" feel lucky?
Statistical closeness implies computational indistinguishability
Project Euler Problem 45
After a few interviews, What should I do after told to wait?
Leaving the USA
Python reimplementation of Lost In Space by Tim Hartnell
Is every sentence we write or utter either true or false?
Dynamic Picklist Value Retrieval
Fantasy Military Arms and Armor: the Dwarven Grand Armory
Relationship between speed and cadence?
Why did Tony's Arc Reactor do this?
Why can't some airports handle heavy aircraft while others do it easily (same runway length)?
How do draw effects during the discard phase work?
Where on Earth is it easiest to survive in the wilderness?
Why has Marx's "Das Kapital" been translated to "Capital" in English and not "The Capital"
How can electricity be positive when electrons are negative?
How do German speakers decide what should be on the left side of the verb?
Can you pop microwave popcorn on a stove?
Bit floating sequence
Why are there no wireless switches?
What exactly is Apple Cider
What is the purpose of the rotating plate in front of the lock?
Compiler optimization of bitwise not operation
Poor management handling of recent sickness and how to approach my return?
AWS Lambda Skill Handler returns before database Get is complete
AWS Lambda “Process exited before completing request”Alexa Skills Kit Lambda Region IssueLambda Alex Skill session attribute is undefinedCan Lambda Invoke An Alexa Skill?Error in Lambda Handler for Alexa Skill using PythonAWS Lambda 'Process exited before completing request'Use Lambda code for an Alexa skillLambda function ends before DynamoDB get ends in Alexa skillScanning DynamoDB table not showing results from the column specified in ProjectionExpressionUnable to properly retrieve read JSON data from DynamoDB database for Alexa skill
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have written my first Lambda to handle an Alexa Skill.
My problem is that the call to the database is clearly asynchronous (I can tell from the order the Console.log messages appear in the Cloud Log.
Here is my Handler.
How do I make it so the return happens after the data is got from the database?
const RemindMeHandler =
canHandle(handlerInput) ,
handle(handlerInput)
console.log('Started Reminder');
var thing="Nothinbg";
/* ========== Read dB ========== */
const params =
TableName: 'ItemsToRecall',
Key:
'Slot': S: '1'
,
;
readDynamoItem(params, myResult=>
console.log('Reminder Results: ' + myResult.data);
thing="Captain";
console.log('thing 1: ' + thing);
);
console.log('Ended Reminder');
function readDynamoItem(params, callback)
var AWS = require('aws-sdk');
AWS.config.update(region: 'eu-west-1');
var docClient = new AWS.DynamoDB();
console.log('Reading item from DynamoDB table');
docClient.getItem(params, function (err, data)
if (err)
callback(err, data);
else
callback('Worked', data);
);
/* ========== Read dB End ========== */
console.log('thing 2: ' + thing);
return handlerInput.responseBuilder
.speak(REMINDER_ACKNOWLEDGE_MESSAGE + thing)
.getResponse();
;
/* ========== Remind Handler End ========== */
aws-lambda alexa
add a comment |
I have written my first Lambda to handle an Alexa Skill.
My problem is that the call to the database is clearly asynchronous (I can tell from the order the Console.log messages appear in the Cloud Log.
Here is my Handler.
How do I make it so the return happens after the data is got from the database?
const RemindMeHandler =
canHandle(handlerInput) ,
handle(handlerInput)
console.log('Started Reminder');
var thing="Nothinbg";
/* ========== Read dB ========== */
const params =
TableName: 'ItemsToRecall',
Key:
'Slot': S: '1'
,
;
readDynamoItem(params, myResult=>
console.log('Reminder Results: ' + myResult.data);
thing="Captain";
console.log('thing 1: ' + thing);
);
console.log('Ended Reminder');
function readDynamoItem(params, callback)
var AWS = require('aws-sdk');
AWS.config.update(region: 'eu-west-1');
var docClient = new AWS.DynamoDB();
console.log('Reading item from DynamoDB table');
docClient.getItem(params, function (err, data)
if (err)
callback(err, data);
else
callback('Worked', data);
);
/* ========== Read dB End ========== */
console.log('thing 2: ' + thing);
return handlerInput.responseBuilder
.speak(REMINDER_ACKNOWLEDGE_MESSAGE + thing)
.getResponse();
;
/* ========== Remind Handler End ========== */
aws-lambda alexa
add a comment |
I have written my first Lambda to handle an Alexa Skill.
My problem is that the call to the database is clearly asynchronous (I can tell from the order the Console.log messages appear in the Cloud Log.
Here is my Handler.
How do I make it so the return happens after the data is got from the database?
const RemindMeHandler =
canHandle(handlerInput) ,
handle(handlerInput)
console.log('Started Reminder');
var thing="Nothinbg";
/* ========== Read dB ========== */
const params =
TableName: 'ItemsToRecall',
Key:
'Slot': S: '1'
,
;
readDynamoItem(params, myResult=>
console.log('Reminder Results: ' + myResult.data);
thing="Captain";
console.log('thing 1: ' + thing);
);
console.log('Ended Reminder');
function readDynamoItem(params, callback)
var AWS = require('aws-sdk');
AWS.config.update(region: 'eu-west-1');
var docClient = new AWS.DynamoDB();
console.log('Reading item from DynamoDB table');
docClient.getItem(params, function (err, data)
if (err)
callback(err, data);
else
callback('Worked', data);
);
/* ========== Read dB End ========== */
console.log('thing 2: ' + thing);
return handlerInput.responseBuilder
.speak(REMINDER_ACKNOWLEDGE_MESSAGE + thing)
.getResponse();
;
/* ========== Remind Handler End ========== */
aws-lambda alexa
I have written my first Lambda to handle an Alexa Skill.
My problem is that the call to the database is clearly asynchronous (I can tell from the order the Console.log messages appear in the Cloud Log.
Here is my Handler.
How do I make it so the return happens after the data is got from the database?
const RemindMeHandler =
canHandle(handlerInput) ,
handle(handlerInput)
console.log('Started Reminder');
var thing="Nothinbg";
/* ========== Read dB ========== */
const params =
TableName: 'ItemsToRecall',
Key:
'Slot': S: '1'
,
;
readDynamoItem(params, myResult=>
console.log('Reminder Results: ' + myResult.data);
thing="Captain";
console.log('thing 1: ' + thing);
);
console.log('Ended Reminder');
function readDynamoItem(params, callback)
var AWS = require('aws-sdk');
AWS.config.update(region: 'eu-west-1');
var docClient = new AWS.DynamoDB();
console.log('Reading item from DynamoDB table');
docClient.getItem(params, function (err, data)
if (err)
callback(err, data);
else
callback('Worked', data);
);
/* ========== Read dB End ========== */
console.log('thing 2: ' + thing);
return handlerInput.responseBuilder
.speak(REMINDER_ACKNOWLEDGE_MESSAGE + thing)
.getResponse();
;
/* ========== Remind Handler End ========== */
aws-lambda alexa
aws-lambda alexa
asked Mar 27 at 13:47
Richard210363Richard210363
6,0964 gold badges27 silver badges51 bronze badges
6,0964 gold badges27 silver badges51 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can wrap the asynchronous and return a promise and then use async/await syntax to get the data. You can check the below. Do note it's not tested.
const RemindMeHandler =
canHandle(handlerInput)
return (
handlerInput.requestEnvelope.request.type === "LaunchRequest" ,
async handle(handlerInput)
console.log("Started Reminder");
let thing = "Nothinbg";
const params =
TableName: "ItemsToRecall",
Key:
Slot: S: "1"
;
const data = await readDynamoItem(params);
console.log("Reminder Results: ", data);
thing = "Captain";
let speechText = thing;
return handlerInput.responseBuilder
.speak(speechText)
.reprompt(speechText)
.getResponse();
;
function readDynamoItem(params)
const AWS = require("aws-sdk");
AWS.config.update( region: "eu-west-1" );
const docClient = new AWS.DynamoDB();
console.log("Reading item from DynamoDB table");
return new Promise((resolve, reject) =>
docClient.getItem(params, function(err, data)
if (err)
reject(err);
else
resolve(data);
);
);
That did it. Ta
– Richard210363
Mar 28 at 19:18
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55378799%2faws-lambda-skill-handler-returns-before-database-get-is-complete%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can wrap the asynchronous and return a promise and then use async/await syntax to get the data. You can check the below. Do note it's not tested.
const RemindMeHandler =
canHandle(handlerInput)
return (
handlerInput.requestEnvelope.request.type === "LaunchRequest" ,
async handle(handlerInput)
console.log("Started Reminder");
let thing = "Nothinbg";
const params =
TableName: "ItemsToRecall",
Key:
Slot: S: "1"
;
const data = await readDynamoItem(params);
console.log("Reminder Results: ", data);
thing = "Captain";
let speechText = thing;
return handlerInput.responseBuilder
.speak(speechText)
.reprompt(speechText)
.getResponse();
;
function readDynamoItem(params)
const AWS = require("aws-sdk");
AWS.config.update( region: "eu-west-1" );
const docClient = new AWS.DynamoDB();
console.log("Reading item from DynamoDB table");
return new Promise((resolve, reject) =>
docClient.getItem(params, function(err, data)
if (err)
reject(err);
else
resolve(data);
);
);
That did it. Ta
– Richard210363
Mar 28 at 19:18
add a comment |
You can wrap the asynchronous and return a promise and then use async/await syntax to get the data. You can check the below. Do note it's not tested.
const RemindMeHandler =
canHandle(handlerInput)
return (
handlerInput.requestEnvelope.request.type === "LaunchRequest" ,
async handle(handlerInput)
console.log("Started Reminder");
let thing = "Nothinbg";
const params =
TableName: "ItemsToRecall",
Key:
Slot: S: "1"
;
const data = await readDynamoItem(params);
console.log("Reminder Results: ", data);
thing = "Captain";
let speechText = thing;
return handlerInput.responseBuilder
.speak(speechText)
.reprompt(speechText)
.getResponse();
;
function readDynamoItem(params)
const AWS = require("aws-sdk");
AWS.config.update( region: "eu-west-1" );
const docClient = new AWS.DynamoDB();
console.log("Reading item from DynamoDB table");
return new Promise((resolve, reject) =>
docClient.getItem(params, function(err, data)
if (err)
reject(err);
else
resolve(data);
);
);
That did it. Ta
– Richard210363
Mar 28 at 19:18
add a comment |
You can wrap the asynchronous and return a promise and then use async/await syntax to get the data. You can check the below. Do note it's not tested.
const RemindMeHandler =
canHandle(handlerInput)
return (
handlerInput.requestEnvelope.request.type === "LaunchRequest" ,
async handle(handlerInput)
console.log("Started Reminder");
let thing = "Nothinbg";
const params =
TableName: "ItemsToRecall",
Key:
Slot: S: "1"
;
const data = await readDynamoItem(params);
console.log("Reminder Results: ", data);
thing = "Captain";
let speechText = thing;
return handlerInput.responseBuilder
.speak(speechText)
.reprompt(speechText)
.getResponse();
;
function readDynamoItem(params)
const AWS = require("aws-sdk");
AWS.config.update( region: "eu-west-1" );
const docClient = new AWS.DynamoDB();
console.log("Reading item from DynamoDB table");
return new Promise((resolve, reject) =>
docClient.getItem(params, function(err, data)
if (err)
reject(err);
else
resolve(data);
);
);
You can wrap the asynchronous and return a promise and then use async/await syntax to get the data. You can check the below. Do note it's not tested.
const RemindMeHandler =
canHandle(handlerInput)
return (
handlerInput.requestEnvelope.request.type === "LaunchRequest" ,
async handle(handlerInput)
console.log("Started Reminder");
let thing = "Nothinbg";
const params =
TableName: "ItemsToRecall",
Key:
Slot: S: "1"
;
const data = await readDynamoItem(params);
console.log("Reminder Results: ", data);
thing = "Captain";
let speechText = thing;
return handlerInput.responseBuilder
.speak(speechText)
.reprompt(speechText)
.getResponse();
;
function readDynamoItem(params)
const AWS = require("aws-sdk");
AWS.config.update( region: "eu-west-1" );
const docClient = new AWS.DynamoDB();
console.log("Reading item from DynamoDB table");
return new Promise((resolve, reject) =>
docClient.getItem(params, function(err, data)
if (err)
reject(err);
else
resolve(data);
);
);
answered Mar 28 at 6:16
shradhashradha
3762 silver badges5 bronze badges
3762 silver badges5 bronze badges
That did it. Ta
– Richard210363
Mar 28 at 19:18
add a comment |
That did it. Ta
– Richard210363
Mar 28 at 19:18
That did it. Ta
– Richard210363
Mar 28 at 19:18
That did it. Ta
– Richard210363
Mar 28 at 19:18
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55378799%2faws-lambda-skill-handler-returns-before-database-get-is-complete%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown