This file contains hidden or 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
| module.exports = async function(context, req) { | |
| const Nexmo = require("nexmo"); | |
| const nexmo = new Nexmo({ | |
| apiKey: process.env["NEXMO_API_KEY"], | |
| apiSecret: process.env["NEXMO_API_SECRET"] | |
| }); | |
| const params = Object.assign(req.query, req.body); |
This file contains hidden or 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
| module.exports = async function(context, req) { | |
| const params = Object.assign(req.query, req.body); | |
| if (params.text) { | |
| context.log("SMS received", params); | |
| } | |
| context.res = {}; | |
| }; |
This file contains hidden or 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
| app.post('/webhooks/inbound-message', (req, res) => { | |
| console.log(req.body); | |
| res.status(200).end(); | |
| }); |
This file contains hidden or 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
| const app = require('express')() | |
| const bodyParser = require('body-parser') | |
| app.use(bodyParser.json()) | |
| app.use(bodyParser.urlencoded({ extended: true })) | |
| app.listen(3000) |
This file contains hidden or 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
| let text = "👋Hello from Nexmo"; | |
| nexmo.channel.send( | |
| { "type": "sms", "number": "TO_NUMBER" }, | |
| { "type": "sms", "number": "Nexmo" }, | |
| { | |
| "content": { | |
| "type": "text", | |
| "text": text | |
| } |
This file contains hidden or 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
| const Nexmo = require('nexmo') | |
| const nexmo = new Nexmo({ | |
| apiKey: NEXMO_API_KEY, | |
| apiSecret: NEXMO_API_SECRET, | |
| applicationId: NEXMO_APPLICATION_ID, | |
| privateKey: NEXMO_APPLICATION_PRIVATE_KEY_PATH | |
| }) |
This file contains hidden or 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
| let text = "👋Hello from Nexmo"; | |
| nexmo.message.sendSms("Nexmo", "TO_NUMBER", text, { | |
| type: "unicode" | |
| }, (err, responseData) => { | |
| if (err) { | |
| console.log(err); | |
| } else { | |
| if (responseData.messages[0]['status'] === "0") { | |
| console.log("Message sent successfully."); |
This file contains hidden or 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
| const Nexmo = require('nexmo') | |
| const nexmo = new Nexmo({ | |
| apiKey: NEXMO_API_KEY, | |
| apiSecret: NEXMO_API_SECRET | |
| }) |
This file contains hidden or 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
| $ touch index.js |
This file contains hidden or 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
| const app = require('express')() | |
| const bodyParser = require('body-parser') | |
| app.use(bodyParser.json()) | |
| app.use(bodyParser.urlencoded({ extended: true })) | |
| app.listen(3000) |
NewerOlder