1

sorry for my english.

I'm new to Alexa skill implementation.

I would like to import a text file (which I have placed in the AWS S3 storage) into the code to be able to read it and insert it within a dataframe but I am not able to do it.

I have this code

class testIntent(AbstractRequestHandler):
 def can_handle(self, handler_input):
    # type: (HandlerInput) -> bool
    return ask_utils.is_intent_name("test")(handler_input)
    
 def handle(self, handler_input):
    # type: (HandlerInput) -> Response
    
    res = utilis.create_presigned_url("Media/test.txt")
    return (
    handler_input.response_builder.speak("{}".format(res)).response
    
    )

That the call of the intent should return a link, I think (?)

While the skill is running the output is "Sorry, I had trouble doing what you asked. Please try again."

I was hoping to take the link, open it, read it and create a dataframe.

Can anyone help me?

1 Answers1

0

Pre signed URL in utils will pass reference to the media. It doesn't pass the actual content. It works fine in case of image/audio files with responsebuilder.setCard() or ssml tags .

But the way responsebuilder.speak() works for plain text is bit different. You need to pass the content not the reference to the content.

Example:

 S3 bucket > mytext.txt > ["content abcd"]

Currently you are passing

responsebuilder.speak(s3-mybucket-mytext.txt) //path

You need to pass :

responsebuilder.speak("content abcd") //content. read it using boto3 

Connect to the file with boto3 client: refer here

Configure the S3 bucket > fetch the file > do read operation > Once text is in lambda, you can send it to Alexa with responsebuilder.speak()

Or If the file is static, you can place the text file in the code itself. Import the file with file modules.