Skip to content

Instantly share code, notes, and snippets.

@DanyF-github
Created October 29, 2021 10:06
Show Gist options
  • Save DanyF-github/47393882a3441f2363f8d73885839540 to your computer and use it in GitHub Desktop.
Save DanyF-github/47393882a3441f2363f8d73885839540 to your computer and use it in GitHub Desktop.
function setUsername(phone, username) {
db.run('INSERT INTO Users (phone, username) VALUES ($phone, $username)', {
$phone: parseInt(phone),
$username: username
}, (err, row) => {
if (err) {
console.error(err);
}
});
vonage.channel.send(
{ type: 'whatsapp', number: phone },
{ type: 'whatsapp', number: process.env.WHATSAPP_NUM },
{ content: {
type: 'text',
text: 'Nice to meet you, ' + username + '! What\'s your email address?'
}}, (e, data) => {
if (e) {
console.error(e);
} else {
db.run('UPDATE State SET state = $state WHERE phone = $phone', {
$phone: parseInt(phone),
$state: states.getEmail
}, (err, row) => {
if (err) {
console.error(err);
}
});
}
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment