Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
app.intent('Default Welcome Intent', (conv) => {
// Asks the user's permission to know their name, for personalization.
conv.ask(new Permission({
context: 'Hi there, to get to know you better',
permissions: 'NAME',
}));
});
app.intent('Default Welcome Intent', (conv) => {
const name = conv.user.storage.userName;
if (!name) {
// Asks the user's permission to know their name, for personalization.
conv.ask(new Permission({
context: 'Hi there, to get to know you better',
permissions: 'NAME',
}));
} else {
conv.ask(`Hi again, ${name}. What's your favorite color?`);
}
});
app.intent('Default Welcome Intent', (conv) => {
// userData(conv) = {}
// Uncomment above to delete the cached permissions on each request
// to force the app to request new permissions from the user
// Location permissions only work for verified users
if (conv.user.verification === 'VERIFIED') {
conv.ask(responses.greetUser);
} else {
conv.ask(new Permission({
context: responses.permissionReason,
permissions: 'NAME',
}));
}
});
app.intent('request_name_permission', conv => {
conv.data.requestedPermission = 'NAME'
if (!conv.user.storage.name) {
return conv.ask(new Permission({
context: responses.permissionReason,
permissions: conv.data.requestedPermission,
}))
}
conv.close(responses.sayName(conv.user.storage.name))
})
app.intent('request_name_permission', conv => {
conv.data.requestedPermission = 'NAME'
if (!conv.user.storage.name) {
return conv.ask(new Permission({
context: responses.permissionReason,
permissions: conv.data.requestedPermission,
}))
}
conv.close(responses.sayName(conv.user.storage.name))
})
order.name = user.displayName;
order.address = user.address;
order.location = user.location;
return saveOrder(order).then(() => {
return closeOrder(assistant, order);
});
} else {
assistant.contexts.set(CTX_ORDER_PIZZA, 5, { order });
if (order.address) {
assistant.ask(new Permission({
context: 'To complete your order we need you name',
permissions: ['NAME']
}));
} else {
assistant.ask(
new Permission({
context: 'To complete your order we need you name and your location',
permissions: ['DEVICE_PRECISE_LOCATION', 'NAME']
})
);
}
}
});
}