I m sorry for my English. I need an alexa skill that reads the contents of a txt file. I think the best solution is to have the file on S3, but I can't find any guide on how to access the file and let alexa read it. I'm trying in various ways for now this is my code.
const ReadStoryIntentHandler = {
canHandle(handlerInput) {
return handlerInput.requestEnvelope.request.type === 'IntentRequest'
&& handlerInput.requestEnvelope.request.intent.name === 'CaptureNameIntent';
},
async handle(handlerInput) {
let speakOut;
let option = {
"Bucket" : "storytellingbucket",
"Key" : "data/testo.txt"
}
await toGetS3(option).
then((response)=>{
console.log(response),
console.log(response.Body.toString()),
speakOut = response
}).catch ((err) => {
console.log(err)
speakOut='there is an error'
})
return handlerInput.responseBuilder
.speak(speakOut)
.getResponse();
}
}
and the function
const toGetS3 = function (options) {
return new Promise((resolve, reject) => {
s3.getObject(options, function (err, data) {
//handle error
if (err) {
reject("Error", err);
}
//success
if (data) {
resolve(data.Body.toString())
}
})
}) }
The code does not work. I have not been able to find a solution for days.