question

newuser-8aeb3f79-e874-4321-b35b-1323020dbfa9 avatar image

Error: Cannot get PersistentAttributes without Persistence adapter '''

Hi! I am trying to create a google calendar event. However, I am very confused by the error I am getting.

sb = StandardSkillBuilder(table_name="AccessToken", auto_create_table = False)

class GoogleIntentHandler(AbstractRequestHandler):
    def can_handle(self, handler_input):
        return ask_utils.is_intent_name("GoogleIntent")(handler_input)
    
    def handle(self, handler_input):
        accessToken = handler_input.request_envelope.context.system.user.access_token
        persistence_attr = handler_input.attributes_manager.persistent_attributes
        persistence_attr['AccessToken'] = accessToken
        handler_input.attributes_manager.save_persistent_attributes()
        
        #For retrieving the access token
        persistence_attr = handler_input.attributes_manager.persistent_attributes
        accessToken = persistence_attr['AccessToken']
        logger.info(f'access token : {accessToken}')
        global service
        service = build('calendar', 'v3', credentials=accessToken) 
        
        event = {
        'summary': 'Test',
        'location': 'At home',
        'description': 'A chance to hear more about Google\'s developer products.',
        'start': {
            'dateTime': '2020-07-29T12:12:10',
            'timeZone': 'America/Los_Angeles',
        },
        'end': {
            'dateTime': '2020-07-29T12:32:47',
            'timeZone': 'America/Los_Angeles',
        }
        }
        event = service.events().insert(calendarId='primary', body=event).execute()
        
        handler_input.response_builder.speak(speak_output)
        return handler_input.response_builder.response 

sb = CustomSkillBuilder(api_client=DefaultApiClient())
sb.add_request_handler(GoogleIntentHandler())

'''
Error: Cannot get PersistentAttributes without Persistence adapter '''
alexa skills kitalexaapipython
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers