Hi There,
I am working on custom alexa skill and i am getting errors in connecting the table in dynamodb with lambda in node js.Please help me with a reference.
Hi There,
I am working on custom alexa skill and i am getting errors in connecting the table in dynamodb with lambda in node js.Please help me with a reference.
This is a snippet of code I wrote to retrieve a value from one of DynamoDB tables and then update the record:
const AWS = require("aws-sdk"); const AWSregion = "us-east-1"; AWS.config.update({ region: AWSregion }); const DYNAMODB_TABLE_NAME = "My Dynamo Table"; const DynamoDB = new AWS.DynamoDB(); const id = "My Id"; let params = { Key: { "id": { S: id } }, TableName: DYNAMODB_TABLE_NAME }; DynamoDB.getItem(params, (err, data) => { if (err) { console.log(err, err.stack); // an error occurred } else { // I have a value in a field called "update". The retrieved data is in // data.Item.update.S const oldValue = data.Item.update.S; // Update the value in "update" for "id": const newValue = "New Data"; params = { Item: { "id": { S: id }, "update": { S: newValue } }, TableName: DYNAMODB_TABLE_NAME }; DynamoDB.putItem(params, (err, data) => { if (err) { console.log(err, err.stack); // an error occurred } else { // Update was successful } }); } });
Where is the connection between dynamodb with alexa? the code is mostly just dynamodb.
Hello and thank you for your message.
As @Aardvark mentioned on their reply, this is just as snippet. You need to add it to your already working skill endpoint in order to have it connect to Alexa.
Regards,
Barry
Thanks a lot
Yes i have done that.I need the code to fetch the data which i am unable to do