question

newuser-131607c2-5050-40de-918b-0d0494dc3c18 avatar image

Set id of slot programmatically when using addDelegateDirective Node.JS

I am connecting an intent from an Amazon.YES_INTENT using addDelegateDirective, this intent needs to have a slot with a value that I keep in DynamoDB, but also, I need to pass it the ID of this slot value, since I need it to point to an address of a REST API.

How can I pass the id to this slot in addition to its value?

This is my current response builder:


return responseBuilder
                .addDelegateDirective({
                  name: 'IntentToCall',
                  confirmationStatus: 'NONE',
                  slots: {
                    country: {
                      name: 'country',
                      value: persistentAttrs['lastCountryConsulted'].value,
                      confirmationStatus: 'NONE'
                    }
                  }
                })




alexa skills kitalexaalexa skillsnodejs
10 |5000

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

1 Answer

Amazon_Bernardo Bezerra avatar image
Amazon_Bernardo Bezerra answered

Hello and thank you for your message.

I would suggest you define the value before passing it to the responseBuilder:

const lastCountry = persistentAttrs['lastCountryConsulted'].value
console.log(`lastCountry: ${lastCountry}`) // just checking if it is the expected value

return responseBuilder
    .addDelegateeDirective({
        name: 'IntentToCall',
        confirmationStatus: 'NONE',
        slots: {
            country: {
                name: 'country',
                value: lastCountry,
                confirmationStatus: 'NONE'
            }
        }
    })

Regards,
Barry

10 |5000

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