-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Messages Sandbox snippets (#145)
- Loading branch information
1 parent
e0afd35
commit 2726610
Showing
5 changed files
with
113 additions
and
13 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require('dotenv').config({ path: __dirname + '/../../.env' }); | ||
|
||
const VONAGE_API_KEY = process.env.VONAGE_API_KEY; | ||
const VONAGE_API_SECRET = process.env.VONAGE_API_SECRET; | ||
const VONAGE_APPLICATION_ID = process.env.VONAGE_APPLICATION_ID; | ||
const VONAGE_PRIVATE_KEY = process.env.VONAGE_PRIVATE_KEY; | ||
|
||
const MESSAGES_SANDBOX_URL = process.env.MESSAGES_SANDBOX_URL; | ||
const MESSAGES_SANDBOX_FB_ID = process.env.MESSAGES_SANDBOX_FB_ID; | ||
const MESSAGES_SANDBOX_ALLOW_LISTED_FB_RECIPIENT_ID = process.env.MESSAGES_SANDBOX_ALLOW_LISTED_FB_RECIPIENT_ID; | ||
|
||
const { Vonage } = require('@vonage/server-sdk'); | ||
const { MessengerText } = require('@vonage/messages'); | ||
|
||
const vonage = new Vonage({ | ||
apiKey: VONAGE_API_KEY, | ||
apiSecret: VONAGE_API_SECRET, | ||
applicationId: VONAGE_APPLICATION_ID, | ||
privateKey: VONAGE_PRIVATE_KEY, | ||
}, | ||
{ | ||
apiHost: MESSAGES_SANDBOX_URL | ||
}); | ||
|
||
|
||
vonage.messages.send( | ||
new MessengerText({ | ||
text: `This is a Facebook Messenger text message sent using the Messages API via the Messages Sandbox`, | ||
to: MESSAGES_SANDBOX_FB_ID, | ||
from: MESSAGES_SANDBOX_ALLOW_LISTED_FB_RECIPIENT_ID, | ||
}), | ||
) | ||
.then(resp => console.log(resp.messageUUID)) | ||
.catch(err => console.error(err)); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require('dotenv').config({ path: __dirname + '/../../.env' }); | ||
|
||
const VONAGE_API_KEY = process.env.VONAGE_API_KEY; | ||
const VONAGE_API_SECRET = process.env.VONAGE_API_SECRET; | ||
const VONAGE_APPLICATION_ID = process.env.VONAGE_APPLICATION_ID; | ||
const VONAGE_PRIVATE_KEY = process.env.VONAGE_PRIVATE_KEY; | ||
|
||
const MESSAGES_SANDBOX_URL = process.env.MESSAGES_SANDBOX_URL; | ||
const MESSAGES_SANDBOX_ALLOW_LISTED_TO_NUMBER = process.env.MESSAGES_SANDBOX_ALLOW_LISTED_TO_NUMBER; | ||
const MESSAGES_SANDBOX_VIBER_SERVICE_ID = process.env.MESSAGES_SANDBOX_VIBER_SERVICE_ID; | ||
|
||
const { Vonage } = require('@vonage/server-sdk'); | ||
const { ViberText } = require('@vonage/messages'); | ||
|
||
const vonage = new Vonage({ | ||
apiKey: VONAGE_API_KEY, | ||
apiSecret: VONAGE_API_SECRET, | ||
applicationId: VONAGE_APPLICATION_ID, | ||
privateKey: VONAGE_PRIVATE_KEY, | ||
}, | ||
{ | ||
apiHost: MESSAGES_SANDBOX_URL | ||
}); | ||
|
||
vonage.messages.send( | ||
new ViberText({ | ||
text: `This is a Viber Service Message text message sent using the Messages API via the Messages Sandbox`, | ||
to: MESSAGES_SANDBOX_ALLOW_LISTED_TO_NUMBER, | ||
from: MESSAGES_SANDBOX_VIBER_SERVICE_ID, | ||
}), | ||
) | ||
.then(resp => console.log(resp.messageUUID)) | ||
.catch(err => console.error(err)); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require('dotenv').config({ path: __dirname + '/../../.env' }); | ||
|
||
const VONAGE_API_KEY = process.env.VONAGE_API_KEY; | ||
const VONAGE_API_SECRET = process.env.VONAGE_API_SECRET; | ||
const VONAGE_APPLICATION_ID = process.env.VONAGE_APPLICATION_ID; | ||
const VONAGE_PRIVATE_KEY = process.env.VONAGE_PRIVATE_KEY; | ||
|
||
const MESSAGES_SANDBOX_URL = process.env.MESSAGES_SANDBOX_URL; | ||
const MESSAGES_SANDBOX_ALLOW_LISTED_TO_NUMBER = process.env.MESSAGES_SANDBOX_ALLOW_LISTED_TO_NUMBER; | ||
const MESSAGES_SANDBOX_WHATSAPP_NUMBER = process.env.MESSAGES_SANDBOX_WHATSAPP_NUMBER; | ||
|
||
const { Vonage } = require('@vonage/server-sdk'); | ||
const { WhatsAppText } = require('@vonage/messages'); | ||
|
||
const vonage = new Vonage({ | ||
apiKey: VONAGE_API_KEY, | ||
apiSecret: VONAGE_API_SECRET, | ||
applicationId: VONAGE_APPLICATION_ID, | ||
privateKey: VONAGE_PRIVATE_KEY, | ||
}, | ||
{ | ||
apiHost: MESSAGES_SANDBOX_URL | ||
}); | ||
|
||
vonage.messages.send( | ||
new WhatsAppText({ | ||
text: "This is a WhatsApp Message text message sent using the Messages API", | ||
to: MESSAGES_SANDBOX_ALLOW_LISTED_TO_NUMBER, | ||
from: MESSAGES_SANDBOX_WHATSAPP_NUMBER, | ||
}), | ||
) | ||
.then(resp => console.log(resp.messageUUID)) | ||
.catch(err => console.error(err)); |
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