Code Monkey home page Code Monkey logo

Comments (4)

deegles avatar deegles commented on June 3, 2024 1

To override a built-in function such as :ask, simply register a handler with the same name.

For metrics logging, I would recommend simply logging it in your exports.handler function in index.js before your function code is executed.

E.g.

exports.handler = function(event, context, callback) {

    // Log incoming event or just the intent
    console.log('event:\n' + JSON.stringify(event, null, 4));

    var alexa = Alexa.handler(event, context);
    alexa.registerHandlers(...)

    // Log with a callback
    LogEventAsync(event, function() {
        alexa.execute();
    });
}

function LogEventAsync(event, callback) {
    // Async call to emit metric 
    callback();
}

from alexa-skills-kit-sdk-for-nodejs.

acinader avatar acinader commented on June 3, 2024

@deegles so i want to log the response in addition to the event.

I was figuring that I would need to override :responseReady. Got a better suggestion?

from alexa-skills-kit-sdk-for-nodejs.

deegles avatar deegles commented on June 3, 2024

Hi Acinader,

One approach is to wrap your context.succeed function. Try the following in your exports.handler function, before calling alexa.execute().

You can do the same with context.fail

var succeed = context.succeed;
context.succeed = function (response) {
    console.log('Response:\n' + JSON.stringify(response, null, 4));
    succeed(response);
}

from alexa-skills-kit-sdk-for-nodejs.

acinader avatar acinader commented on June 3, 2024

👍 thanks

from alexa-skills-kit-sdk-for-nodejs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.