question

mindrabbit avatar image
mindrabbit asked ·

How to queue multiple recordings for a Flash briefing?

In regards to a Flash-briefing skill that I run: I have a JSON file that I've been updating each day with one replacement audio clip which works 100% fine. The issue I would like to surmount is the task of daily updating the URL reference of only one recording EACH day. So what I'm getting at is I would like to somehow achieve the code that will allow me to load in say five or seven separate mp3 files into URLs within the JSON code which would allow me to only update my JSON once every week or whatever.

I have attempted duplicating the primary block of code in addition to the initial, replacing the mp3, and changing the updateDate to a day in the future without any luck. This method fails in that once Alexa is called upon to read off the flash-briefing it plays the first recording then the second consecutively after. I would like to reserve that second recording for a future date.

Does anyone have a solution?

alexa voice serviceflash briefing
10 |2000 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.

Darin Pope avatar image
Darin Pope answered ·

Unfortunately, currently there is no way to do what you want to do other than publishing a fresh update daily.

10 |2000 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.

Jenn@amazon avatar image
Jenn@amazon answered ·

You could write a script to update the item in the FB feed and schedule it to run once a day.

1 comment
10 |2000 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.

Jenn, could you point me to what this script would look like?

My JSON coding ability is rather lackluster so I have not a clue regarding how much learning would be needed in order to execute the script for this.

If it's too cumbersome to toss my way, could you briefly give me an idea of what I need to look into? Thanks!

0 Likes 0 ·
Jenn@amazon avatar image
Jenn@amazon answered ·

Here's one way of automating updating the Feed daily:

Using a Lambda Function, this Tutorial should get you started on writing a file to S3. The S3 link will be the feed URL.

You could have a 'source file' that holds the URL for each day of the week, something like (you can use a different Key, like the date):

{
    "Sunday": "<url>",
    "Monday": "<url>",
    "Tuesday": "<url>",
    etc.
}

The Lambda function can read the entry corresponding to the day and update the S3 file that's acting as your feed url with the current date and URL.

In CloudWatch, set a daily Event to trigger the Lambda function on a schedule.

5 comments
10 |2000 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.

So I created a daily trigger. Also, I tried setting up the code. I'm uncertain as how to properly script in the parameters that are used in the getKeyName function.. I attempted to point it to my bucket, an mp3 file, and the folder in which it is in. I know this has a tremendous chance of looking totally wrong.. Lol.

Also, the source file that you speak of, is your provided example of script supposed to be modified aside from the URL? I'm speaking in terms of proper syntax, does the "Monday" remain the same even with quotations, and also would the URL of my uploaded .mp3s sit within quotations as well, e.g "https://yadadada.com/bla" ?

0 Likes 0 ·
lambdacode.png (48.7 KiB)
dailytrigger.png (35.2 KiB)

I put together some code that should work. (I haven't tested it, but should point you in the right direction)

The only thing you'll need to update in the 'sourceFile' is the URLs for each of the days.

Using the example code, the content of the S3 file that's used for the feed should look like:

{
    "uid ": "2018-02-23T18:40:00.170Z ",
    "updateDate ": "2018-02-23T18:40:00.170Z ",
    "titleText ": "My title here ",
    "redirectionUrl ": "http://my.url.com/",
    "streamUrl": "URL 6"
}
0 Likes 0 ·

Okay thank you. I'll pick away at this. It may take me a chunk of time to get my head wrapped around this and to get it to work. I have a strong feeling that I'll return with more questions in regards to this functionality. Thank you again thus far

0 Likes 0 ·
Show more comments