Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (phoneNumberSequenceCount === 1) {
this.$speech.t('component-GetPhoneNumber.sequence-question');
this.$reprompt.t('component-GetPhoneNumber.sequence-reprompt');
return this.ask(this.$speech, this.$reprompt);
}
else if (phoneNumberSequenceCount === 2) {
this.$speech.t('component-GetPhoneNumber.sequence-last-digits-question');
this.$reprompt.t('component-GetPhoneNumber.sequence-last-digits-reprompt');
return this.ask(this.$speech, this.$reprompt);
}
else {
// validate phone number
const region = this.$request!.getLocale().split('-')[1]; // e.g. "en-US" -> "US"
let phoneNumber: PhoneNumber = new PhoneNumber();
try {
phoneNumber = phoneNumberUtilInstance.parse(this.$session.$data.COMPONENT_GetPhoneNumber.phoneNumberRaw, region);
} catch (error) {
return invalidNumber(this);
}
if (!phoneNumberUtilInstance.isValidNumber(phoneNumber)) {
return invalidNumber(this);
}
const formattedPhoneNumber = formatPhoneNumber(phoneNumber);
this.$components.GetPhoneNumber.data.phoneNumber = formattedPhoneNumber;
return sendComponentResponse(this, 'SUCCESSFUL');
}
sequence = sequence.toString();
}
this.$session.$data.COMPONENT_GetPhoneNumber.phoneNumberRaw += sequence;
if (phoneNumberSequenceCount === 1) {
this.$speech.t('component-GetPhoneNumber.sequence-question');
this.$reprompt.t('component-GetPhoneNumber.sequence-reprompt');
return this.ask(this.$speech, this.$reprompt);
}
else if (phoneNumberSequenceCount === 2) {
this.$speech.t('component-GetPhoneNumber.sequence-last-digits-question');
this.$reprompt.t('component-GetPhoneNumber.sequence-last-digits-reprompt');
return this.ask(this.$speech, this.$reprompt);
}
else {
const region = this.$request.getLocale().split('-')[1];
let phoneNumber = new PhoneNumber();
try {
phoneNumber = phoneNumberUtilInstance.parse(this.$session.$data.COMPONENT_GetPhoneNumber.phoneNumberRaw, region);
}
catch (error) {
return invalidNumber(this);
}
if (!phoneNumberUtilInstance.isValidNumber(phoneNumber)) {
return invalidNumber(this);
}
const formattedPhoneNumber = formatPhoneNumber(phoneNumber);
this.$components.GetPhoneNumber.data.phoneNumber = formattedPhoneNumber;
return sendComponentResponse(this, 'SUCCESSFUL');
}
},
NoIntent() {