Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const reminder = user.reminders[0];
await dc.prompt('confirmPrompt', `Are you sure you want to delete the "${reminder.title}" reminder?`);
},
async function(dc, confirm) {
if (confirm) {
const user = state.user(dc.context);
user.reminders = [];
await dc.context.sendActivity(`reminder deleted...`);
} else {
await dc.context.sendActivity(`ok...`);
}
}
]);
dialogs.add('choicePrompt', new ChoicePrompt());
dialogs.add('confirmPrompt', new ConfirmPrompt());
//-----------------------------------------------
// Show Reminders
//-----------------------------------------------
dialogs.add('showReminders', [
async function(dc) {
let msg = `No reminders found.`;
const user = state.user(dc.context);
if (user.reminders.length > 0) {
msg = `**Current Reminders**\n\n`;
let connector = '';
user.reminders.forEach(reminder => {
msg += connector + `- ${reminder.title} (${reminder.time})`;
connector = '\n';
});
this.askForUserName.bind(this),
this.greetUser.bind(this)
]));
// Add get user name prompt
this.addDialog(new GetUserNamePrompt(ASK_USER_NAME_PROMPT,
botConfig,
userProfileAccessor,
conversationState,
onTurnAccessor));
// This dialog is multi-turn capable and also interruptable. Add interruptionDispatcherDialog
this.addDialog(new InterruptionDispatcher(onTurnAccessor, conversationState, userProfileAccessor, botConfig, reservationAccessor));
// When user decides to abandon this dialog, we need to confirm user action. Add confirmation prompt.
this.addDialog(new ConfirmPrompt(CONFIRM_CANCEL_PROMPT));
}
/**
},
function (dc, value) {
return __awaiter(this, void 0, void 0, function* () {
if (value) {
// Clear conversation state
yield dc.context.sendActivity(`Ok... Goodbye`);
conversationState.clear(dc.context);
}
else {
yield dc.context.sendActivity(`Ok...`);
}
return dc.endDialog();
});
}
]);
this.dialogs.add('confirmPrompt', new botbuilder_dialogs_1.ConfirmPrompt());
}
onTurn(context, next) {
this.getAllRequiredProperties.bind(this),
this.bookTable.bind(this)
]));
// Get location, date, time & party size prompt.
this.addDialog(new GetLocDateTimePartySizePrompt(GET_LOCATION_DATE_TIME_PARTY_SIZE_PROMPT,
botConfig,
reservationsAccessor,
onTurnAccessor,
userProfileAccessor));
// This dialog is interruptable. So add interruptionDispatcherDialog
this.addDialog(new InterruptionDispatcher(onTurnAccessor, conversationState, userProfileAccessor, botConfig, reservationsAccessor));
// When user decides to abandon this dialog, we need to confirm user action. Add confirmation prompt
this.addDialog(new ConfirmPrompt(CONFIRM_CANCEL_PROMPT));
}
// Continue the current dialog
await dc.continueDialog();
// Show menu if no response sent
if (!context.responded) {
await dc.beginDialog('mainMenu');
}
}
});
});
const dialogs = new DialogSet();
// Add prompts
dialogs.add('choicePrompt', new ChoicePrompt());
dialogs.add('confirmPrompt', new ConfirmPrompt());
dialogs.add('datetimePrompt', new DatetimePrompt());
dialogs.add('numberPrompt', new NumberPrompt());
dialogs.add('textPrompt', new TextPrompt());
dialogs.add('attachmentPrompt', new AttachmentPrompt());
//-----------------------------------------------
// Main Menu
//-----------------------------------------------
dialogs.add('mainMenu', [
async function(dc) {
function choice(title: string, value: string): Choice {
return {
value: value,
action: { type: ActionTypes.ImBack, title: title, value: title }
async function (dc) {
await dc.prompt('confirmPrompt', `This will end any active tasks. Are you sure?`);
},
async function (dc, value: boolean) {
if (value) {
// Clear conversation state
await dc.context.sendActivity(`Ok... Goodbye`);
conversationState.clear(dc.context);
} else {
await dc.context.sendActivity(`Ok...`);
}
return dc.endDialog();
}
]);
this.dialogs.add('confirmPrompt', new ConfirmPrompt());
}
constructor(id: string) {
super(id || 'bookingDialog');
this.addDialog(new TextPrompt(TEXT_PROMPT))
.addDialog(new ConfirmPrompt(CONFIRM_PROMPT))
.addDialog(new DateResolverDialog(DATE_RESOLVER_DIALOG))
.addDialog(new WaterfallDialog(WATERFALL_DIALOG, [
this.destinationStep.bind(this),
this.originStep.bind(this),
this.travelDateStep.bind(this),
this.confirmStep.bind(this),
this.finalStep.bind(this)
]));
this.initialDialogId = WATERFALL_DIALOG;
}
constructor() {
super(CancelDialog.name);
this.initialDialogId = CancelDialog.name;
const cancel = [
CancelDialog.AskToCancel.bind(this),
CancelDialog.FinishCancelDialog.bind(this)
];
this.addDialog(new WaterfallDialog(this.initialDialogId, cancel));
this.addDialog(new ConfirmPrompt(DialogIds.CancelPrompt));
}
constructor(id) {
super(id || 'bookingDialog');
this.addDialog(new TextPrompt(TEXT_PROMPT))
.addDialog(new ConfirmPrompt(CONFIRM_PROMPT))
.addDialog(new DateResolverDialog(DATE_RESOLVER_DIALOG))
.addDialog(new WaterfallDialog(WATERFALL_DIALOG, [
this.destinationStep.bind(this),
this.originStep.bind(this),
this.travelDateStep.bind(this),
this.confirmStep.bind(this),
this.finalStep.bind(this)
]));
this.initialDialogId = WATERFALL_DIALOG;
}
constructor() {
super('bookingDialog');
const textPrompt = new TextPrompt(TEXT_PROMPT);
const confirmPrompt = new ConfirmPrompt(CONFIRM_PROMPT);
const dateResolveDialog = new DateResolverDialog(DATE_RESOLVER_DIALOG);
const waterFallDialog = new WaterfallDialog(WATERFALL_DIALOG, [
this.destinationStep.bind(this),
this.originStep.bind(this),
this.travelDateStep.bind(this),
this.confirmStep.bind(this),
this.finalStep.bind(this)
]);
this.addDialog(textPrompt)
.addDialog(confirmPrompt)
.addDialog(dateResolveDialog)
.addDialog(waterFallDialog);