Skip to content

Commit

Permalink
add request
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexLakatos committed Sep 9, 2019
1 parent 6d67bf5 commit 834a805
Show file tree
Hide file tree
Showing 3 changed files with 366 additions and 15 deletions.
7 changes: 5 additions & 2 deletions autoresponder.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,19 @@ var text = "👋Hello from Nexmo";

app.post('/webhooks/inbound', (req, res) => {
console.log(req.body)
request(`http://numbersapi.com/${req.body.text}`, (error, response, body) => {

var number = parseInt(req.body.text) || 42;

request(`http://numbersapi.com/${number}`, (error, response, body) => {
if (error) {
text = "The Numbers API has thrown an error."
} else {
text = body
}

nexmo.channel.send(
{ "type": "sms", "number": process.env.TO_NUMBER },
{ "type": "sms", "number": req.body.msisdn },
{ "type": "sms", "number": req.body.to },
{
"content": {
"type": "text",
Expand Down
Loading

0 comments on commit 834a805

Please sign in to comment.