-
-
Save DanyF-github/47393882a3441f2363f8d73885839540 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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