Handle APL OnClick UserEvent

amazon-alexa

#1

Hi there,

I am using APL to render list items on the screen. I don’t know how to handle the onclick event when clicked on any item. As far as I know in native Alexa
we handle it using the ‘Alexa.Presentation.APL.UserEvent’ but not sure how to do it in jovo?


#2

Hi Jade,

I don’t know if you solved your problem, but I worked on something similar today. I was able to handle a UserEvent from an APL TouchWrapper using an ON_ELEMENT_SELECTED() handler in Jovo. Inside the handler, I was able to break down the this.$request.request to get the information that I needed to process the touch event (e.g. .type was set to UserEvent and .arguments had the argument list that I defined in the APL JSON).

Hope this helps.


#3

Hey @Ben_Hartman this still isn’t working for me.

here’s our ON_ELEMENT_SELECTED() handler in Jovo right now:

// Triggers when a button is pressed on a screen
    ON_ELEMENT_SELECTED() {
        console.log("ON ELEMENT SELECTED!!!!!!!!!!!!!!!");
        console.log(this.$request.request.arguments[1]);
        this.tell("Hello World!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
    },

Our server receives the requests.However, our ON_ELEMENT_SELECTED() Intent is never invoked.

Our server receives the requests.However, our ON_ELEMENT_SELECTED() Intent is never invoked.

Any insight on handling these events?


#4

Update: response from @gshenar

“I’m not sure too much about jovos internal handling of this event, I usually have to dive into the source when I run into something like this. If u look at the request, my guess is it’s not a standard intent request right?”

image

Here is the request we receive on touch event:

"request": {
		"type": "Alexa.Presentation.APL.UserEvent",
		"requestId": "amzn1.echo-api.request.46575083-21a8-42f4-b40a-255d412d796f",
		"timestamp": "2020-04-16T23:25:09Z",
		"locale": "en-US",
		"arguments": [
			"ItemSelected",
			"ConnectIntent"
		],
		"components": {},
		"source": {
			"type": "TouchWrapper",
			"handler": "Press",
			"id": ""
		},
		"token": ""
	}

I’m going to dig around source code.

Any idea how we can handle these events using Jovo?


#5

My initial thought is the reason you are not seeing the ON_ELEMENT_SELECTED() Intent being invoked is because you are using the ‘tell’ method and not ‘ask’. Try it with ask and see if it works. Since ‘tell’ tells Alexa that the session should close, perhaps the device is not listening for additional events.


#6

One thing I noticed is that the token in the request is empty. How does your TouchWrapper look like?