question

Boltd_Dev avatar image
Boltd_Dev asked ·

Alexa Skills Kit: How to call custom intent from another intent in ASK sdk V2

Hi I have been using and developing skills on Alexa since quite few months. Recently I updated to the ask sdk version 2. I find everything cool and stuck nowhere.

I couldn't find a way to emit an intent now. Like earlier we were able to call Intent from another Intent in following manner:

this.emitWithState(<intent name here>);

Anybody know how to achieve this in ask sdk V2?

Any help would be highly appreciated.

alexa skills kitnode_jssdk v2
10 |2000 characters needed characters left characters exceeded

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

Anand@Amazon avatar image
Anand@Amazon answered ·

Hello Boltd_Dev,

Thanks for posting !!!

You can send state data into session attributes and check the same state data and Intent name in CanHandle function to perform your logic.

const GetEmitFunction = {
	canHandle(handlerInput){
		const attributes = handlerInput.attributesManager.getSessionAttributes();
		const request = handlerInput.requestEnvelope.request;
		// add State data into Session attributes in different function and check it here if it matches//
		return attributes.state === states.STATE &&
			request.type === 'IntentRequest' &&
			request.intent.name === 'intent name here';
	},

	handle(handlerInput){
		<your logic code goes here>
	}
}

Check sample code here to get more details.

2 comments
10 |2000 characters needed characters left characters exceeded

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

if you have an idea in python how to call custom intent in another intent please share

0 Likes 0 ·
Gaetano@Amazon avatar image Gaetano@Amazon ♦ newuser-b27eb1e7-aeb3-4e96-b715-0fd0ea7ca76c ·

Hi,

Please have a look at the Dialog.Delegate directive here:
https://developer.amazon.com/en-US/docs/alexa/custom-skills/dialog-interface-reference.html#delegate

Se the "Change the intent or update slot values during the dialog" paragraph for additional info.

Regards,
Gaetano


0 Likes 0 ·
newuser-b4531b6b-c099-43ed-b1ab-c93dccdac271 avatar image
newuser-b4531b6b-c099-43ed-b1ab-c93dccdac271 answered ·

try this

the intent name will come within the single quotes

this.emitWithState('intent name here');

10 |2000 characters needed characters left characters exceeded

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