Alexa Python SDK (with Flask)

Create a Skill API key

Each Skill needs its own API key for tracking.

Create a Skill to get an API key.

Install Dashbot Python SDK

pip install dashbot

Import the Dashbot library

from dashbot import alexa

Initialize Dashbot

Use the API key created above.

dba = alexa.alexa(process.env.DASHBOT_API_KEY)

Create the Global Request & Response Interceptors

from ask_sdk_core.serialize import DefaultSerializer
ds=DefaultSerializer()

@sb.global_request_interceptor()
def request_logger(handler_input):
    serializedRequest=ds.serialize(handler_input.request_envelope)
    dba.logIncoming(serializedRequest)

@sb.global_response_interceptor()
def response_logger(handler_input, response):
    serializedRequest=ds.serialize(handler_input.request_envelope)
    serializedResponse=ds.serialize(response)
    dba.logOutgoing(serializedRequest,serializedResponse)
Close Menu