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;








1















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 ========== */









share|improve this question






























    1















    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 ========== */









    share|improve this question


























      1












      1








      1








      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 ========== */









      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 27 at 13:47









      Richard210363Richard210363

      6,0964 gold badges27 silver badges51 bronze badges




      6,0964 gold badges27 silver badges51 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          1
















          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);

          );
          );






          share|improve this answer

























          • That did it. Ta

            – Richard210363
            Mar 28 at 19:18










          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
          );



          );














          draft saved

          draft discarded
















          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









          1
















          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);

          );
          );






          share|improve this answer

























          • That did it. Ta

            – Richard210363
            Mar 28 at 19:18















          1
















          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);

          );
          );






          share|improve this answer

























          • That did it. Ta

            – Richard210363
            Mar 28 at 19:18













          1














          1










          1









          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);

          );
          );






          share|improve this answer













          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);

          );
          );







          share|improve this answer












          share|improve this answer



          share|improve this answer










          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

















          • 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








          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.




















          draft saved

          draft discarded















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

          해남서초등학교 학교 연혁 학교 동문 외부 링크 둘러보기 메뉴북위 34° 34′ 21″ 동경 126° 35′ 50″ / 북위 34.5726385° 동경 126.5972670°  / 34.5726385; 126.5972670해남서초등학교eh