In my ‘langauge’ journey it gets changed to hindi. But if I invoke other journeys then english language is used. How can I solve this?
Hi @akshay , did you set the targetLanguage
to hindi in the main function ?
Yes, this is my main function
app.customOptions = {
minConfidence: 0.7,
i18n: true
}
app.memory.get(‘botLanguage’).then((targetLanguage) => {
if (targetLanguage) {
app.customOptions.targetLanguage = targetLanguage;
}
}, (error) => {
app.customOptions.targetLanguage = ‘en’;
});
return app.start(app.customOptions);
I think issue is in your code, @akshay. In your main function, use the following code:
app.customOptions = {
minConfidence: 0.7,
i18n: true
}
app.memory.get(‘botLanguage’).then((targetLang) => {
return app.start({…app.customOptions, targetLanguage:targetLang});
}).catch((error) => {
return app.start({…app.customOptions, targetLanguage:‘en’});
});
Still, it’s not changing. I have a ‘language’ journey and in response, I’m calling this function
return new Promise(resolve => {
// Your logic goes here
let userChoice = app.context.steps[‘language’];
let language= '';
if(userChoice === 'English') {
language = 'en';
} else {
language = 'hi';
}
app.options.targetLanguage = language;
app.memory.set('botLangauge', language).then(() => {
app.sendTextMessage(app.renderMessage('language-selected', {}, `Language has been changed to ${language} for you!`)).then(() => {
resolve();
});
});
});
Also, I’d configured every other journey in Hindi too
@akshay, I have to see the bot flow to identify the issue. So, Can you give me admin
access to the bot ? ( My Email: amudhan@yellowmessenger.com )
Once this is done, You can revoke my access anytime.
Okay @Amudhan_S . I’d sent you the admin access invite
Hey @akshay , I have made some changes and now your bot changes the language according to the user input in all journeys.
Changes I have made:
-
In the
languageValidator
function, I have set the bot’s Target Language and I have set the memory value. -
Another small change is, Inside your
changeLanguageAction
function, I have replacedapp.renderMessage()
with justapp.sendTextMessage()
.
Note:
-
I am not sure Why you have been setting the step value inside the
languageValidator
function. Only After setting the value, it comes to this function. So there is no need to set the current step’s value after you get it right ? -
Once you get the
language
step value, you can set the memory value in thelanguageValidator
function. You don’t have to wait and set the memory value in thechangeLanguageAction
function which is the response of the language journey. -
In the
changeLanguageAction
function, you have usedapp.renderMessage()
. I am not sure whether we can able to send a variable value inside theapp.renderMessage()
sinceapp.renderMessage()
is used just to send a response (a response that is gonna be same and gonna be used many times) to the user. You can useapp.sendTextMessage()
instead. If you still want to useapp.renderMessage()
, then make sure to configure all the responses you may need in the localization tab.
Okay, I got it. I’ll check with app.renderMessage(). Thank you @Amudhan_S
Thank you @Amudhan_S for this detailed answer and helping a fellow community member.