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

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현