Lambda to Alexa

0

Hello, for a University project I am trying to send data from my AWS Lambda function CloudWatch logs to my Alexa skill. I need to get this working ASAP. I have seen videos saying you need to add the 'Alexa Skills Kit' as a trigger to be able to do so, however this is not showing as an option. I have tried using 'Alexa' as the trigger but I cannot get it working. Just a quick outline of what i have done so far: I have coded my Lambda function to collect form data and store it in my CloudWatch logs automatically, each time a form is submitted the response is sent to my CloudWatch logs. I want my Alexa skill to read these responses out. So far, I have managed to code my AWS Lambda function to extract the response from a form. I now require to send these responses to my Alexa skill so it can read them out loud. I have been using the AWS management console to do this so far. These form responses are automatically collected and stored in my AWS CloudWatch logs. I have done everything up to this point, but the main feature is to get the Alexa skill to read these responses out loud and I am not sure how to code my Lambda function to do this, or how to make the Alexa do this. I know how to set an Alexa skill up i just need help linking the two together so it can Read the responses out.

  • If anyone requires any further information please let me know and I will provide this!

1 Answer
3

Some suggestion regarding to Lambda function to handle Alexa requests:

const Alexa = require('ask-sdk-core');

exports.handler = async (event) => {
    console.log("Received event:", JSON.stringify(event));

    if (event.request.type === "LaunchRequest") {
        return {
            version: "1.0",
            response: {
                outputSpeech: {
                    type: "PlainText",
                    text: "Welcome! I can read your form responses."
                },
                shouldEndSession: false
            }
        };
    }

    if (event.request.type === "IntentRequest" && event.request.intent.name === "ReadFormDataIntent") {
        const formData = await getFormDataFromCloudWatch(); // Function to fetch logs
        return {
            version: "1.0",
            response: {
                outputSpeech: {
                    type: "PlainText",
                    text: `Here is the latest form response: ${formData}`
                },
                shouldEndSession: false
            }
        };
    }
};

async function getFormDataFromCloudWatch() {
    // Fetch logs from CloudWatch (use AWS SDK)
    return "Sample form response"; // Replace with actual log retrieval logic
}
EXPERT
answered a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions