question

newuser-bc8c319b-1c03-49c3-9615-37b8546eef1b avatar image

I want to add data to DynamoDB table using BatchWriteItem (like Key-Value pair). Can some please suggest me how to do?

This my code

Skill ID - amzn1.ask.skill.4c5e3940-5da8-41ac-afd9-54a164ed9523

const handlers = {
    'LaunchRequest': function () {
        this.emit('SaveMyDoc');
    },
    'SaveMyDoc': function () {
        const greetdataArr = Greet;
        const GreetdataIndex = Math.floor(Math.random() * greetdataArr.length);
        const Greeting = greetdataArr[GreetdataIndex];
        const speechOutput = Greeting;


        this.response.cardRenderer(SKILL_NAME, Greeting);
        this.response.speak(speechOutput);
        this.emit(':ask',speechOutput);
    },
    
    'MyDoc': function () {
            var DocName = this.event.request.intent.slots.docname.value;
            var DocNum = this.event.request.intent.slots.docnum.value;    
            
        if(DocName == this.attributes['DocName']){
            var repName = 'Your'+' '+DocName+' '+'number is already stored'+' '+this.attributes['DocNum'];
            this.emit(':tell',repName);
        }else{
                  
//Here i want to "DocName" and "DocNum" to be added in my DynamoDB table

            var output1 = 'Your'+' '+DocName +' '+ 'number is'+'<break time="1s"><say-as interpret-as="spell-out">'+DocNum+'</say-as></break> ';
            this.emit(':tell',output1);
        }
    },

alexa skills kitlambdaawsdynamodb
10 |3000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Brian@Amazon avatar image
Brian@Amazon answered

If you want to add this data to a DynamoDB table (beyond simple state values) I'd recommend using the AWS SDK for Node.js. The getting started guide contains some examples of how you would load data into a table, and can be found here: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GettingStarted.NodeJs.02.html

10 |3000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.