Separate states into different files


#1

Hello guys,

I’m having issues where I’m trying to separate states into different files in order to structure the code properly.

When I do this using intents, the code separation works properly. Let me give a specific example

On my app.ts I have this code:

app.setHandler(
require(’./intents/Default_Welcome_Intent’),
require(’./intents/Account_Details_Intent’),
require(’./intents/Transfer_Intent’),
{
async LAUNCH() {
return this.toIntent(‘Default_Welcome_Intent’);
}
}
);

The transfer intent is located in another file and at some point executes this code.

this.toStateIntent(‘TransferCheckSlotsState’, ‘CheckSlotsIntent’);

TransferCheckSlotsState: require(’…/intentstates/Transfer_Intent_States/TransferCheckSlotsState’)

THIS CODE ABOVE WORKS.

However I’m trying to do something similar with followupState from the TransferCheckSlotsState (defined in another file)

The code that does not work is shown below

this.followUpState(‘TransferNobankState’).ask(
this.$speech,
this.$reprompt
);

TransferNobankState: require(’…/Transfer_Intent_States/TransferNobankState’),

Any ideas what the issue could be? I can redirect to an intent defined in another file. How do I redirect to another state defined in another file?

Many thanks guys.

Afam


#2

Hey @Afamefuna_Anigbo,

what error do you get? And could you show some code of your TransferNobankState file?

Best regards,
Ruben


#3

I’m dealing with the same issue, I think the error stems from the intent looking at the main app.js when the state has been changed.

In essence how do you refer to a state that is defined in another file with all intents passing through app.js