-
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.
- Loading branch information
Showing
59 changed files
with
2,157 additions
and
1,123 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,27 +1,38 @@ | ||
require('dotenv').config({ path: __dirname + '/../../.env' }); | ||
const { Vonage } = require('@vonage/server-sdk'); | ||
const { Channels } = require('@vonage/messages'); | ||
|
||
const VONAGE_APPLICATION_ID = process.env.VONAGE_APPLICATION_ID; | ||
const VONAGE_PRIVATE_KEY = process.env.VONAGE_PRIVATE_KEY; | ||
const MESSENGER_RECIPIENT_ID = process.env.MESSENGER_RECIPIENT_ID; | ||
const MESSENGER_SENDER_ID = process.env.MESSENGER_SENDER_ID; | ||
const MESSAGES_AUDIO_URL = process.env.MESSAGES_AUDIO_URL; | ||
const MESSAGES_API_URL = process.env.MESSAGES_API_URL; | ||
|
||
const FB_RECIPIENT_ID = process.env.FB_RECIPIENT_ID; | ||
const FB_SENDER_ID = process.env.FB_SENDER_ID; | ||
const AUDIO_URL = process.env.AUDIO_URL; | ||
|
||
const { Vonage } = require('@vonage/server-sdk'); | ||
const { MessengerAudio } = require('@vonage/messages'); | ||
|
||
const vonage = new Vonage({ | ||
applicationId: VONAGE_APPLICATION_ID, | ||
privateKey: VONAGE_PRIVATE_KEY, | ||
}); | ||
/** | ||
* It is best to send messages using JWT instead of basic auth. If you leave out | ||
* apiKey and apiSecret, the messages SDK will send requests using JWT tokens | ||
* | ||
* @link https://developer.vonage.com/en/messages/technical-details#authentication | ||
*/ | ||
const vonage = new Vonage( | ||
{ | ||
applicationId: VONAGE_APPLICATION_ID, | ||
privateKey: VONAGE_PRIVATE_KEY, | ||
}, | ||
{ | ||
...(MESSAGES_API_URL ? {apiHost: MESSAGES_API_URL} : {}), | ||
}, | ||
); | ||
|
||
vonage.messages.send( | ||
new MessengerAudio({ | ||
audio: { | ||
url: AUDIO_URL, | ||
}, | ||
to: FB_RECIPIENT_ID, | ||
from: FB_SENDER_ID, | ||
})) | ||
.then(({ messageUUID}) => console.log(messageUUID)) | ||
vonage.messages.send({ | ||
messaegType: 'audio', | ||
channel: Channels.MESSENGER, | ||
audio: { | ||
url: MESSAGES_AUDIO_URL, | ||
}, | ||
to: MESSENGER_RECIPIENT_ID, | ||
from: MESSENGER_SENDER_ID, | ||
}) | ||
.then(({ messageUUID }) => console.log(messageUUID)) | ||
.catch((error) => console.error(error)); |
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 |
---|---|---|
@@ -1,28 +1,38 @@ | ||
require('dotenv').config({ path: __dirname + '/../../.env' }); | ||
const { Vonage } = require('@vonage/server-sdk'); | ||
const { Channels } = require('@vonage/messages'); | ||
|
||
const VONAGE_APPLICATION_ID = process.env.VONAGE_APPLICATION_ID; | ||
const VONAGE_PRIVATE_KEY = process.env.VONAGE_PRIVATE_KEY; | ||
const MESSENGER_RECIPIENT_ID = process.env.MESSENGER_RECIPIENT_ID; | ||
const MESSENGER_SENDER_ID = process.env.MESSENGER_SENDER_ID; | ||
const MESSAGES_FILE_URL = process.env.MESSAGES_FILE_URL; | ||
const MESSAGES_API_URL = process.env.MESSAGES_API_URL; | ||
|
||
const FB_RECIPIENT_ID = process.env.FB_RECIPIENT_ID; | ||
const FB_SENDER_ID = process.env.FB_SENDER_ID; | ||
const FILE_URL = process.env.FILE_URL; | ||
|
||
const { Vonage } = require('@vonage/server-sdk'); | ||
const { MessengerFile } = require('@vonage/messages'); | ||
|
||
const vonage = new Vonage({ | ||
applicationId: VONAGE_APPLICATION_ID, | ||
privateKey: VONAGE_PRIVATE_KEY, | ||
}); | ||
/** | ||
* It is best to send messages using JWT instead of basic auth. If you leave out | ||
* apiKey and apiSecret, the messages SDK will send requests using JWT tokens | ||
* | ||
* @link https://developer.vonage.com/en/messages/technical-details#authentication | ||
*/ | ||
const vonage = new Vonage( | ||
{ | ||
applicationId: VONAGE_APPLICATION_ID, | ||
privateKey: VONAGE_PRIVATE_KEY, | ||
}, | ||
{ | ||
...(MESSAGES_API_URL ? {apiHost: MESSAGES_API_URL} : {}), | ||
}, | ||
); | ||
|
||
vonage.messages.send( | ||
new MessengerFile({ | ||
file: { | ||
url: FILE_URL, | ||
}, | ||
to: FB_RECIPIENT_ID, | ||
from: FB_SENDER_ID, | ||
}), | ||
) | ||
.then(({ messageUUID}) => console.log(messageUUID)) | ||
vonage.messages.send({ | ||
messageType: 'file', | ||
channel: Channels.MESSENGER, | ||
file: { | ||
url: MESSAGES_FILE_URL, | ||
}, | ||
to: MESSENGER_RECIPIENT_ID, | ||
from: MESSENGER_SENDER_ID, | ||
}) | ||
.then(({ messageUUID }) => console.log(messageUUID)) | ||
.catch((error) => console.error(error)); |
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 |
---|---|---|
@@ -1,28 +1,38 @@ | ||
require('dotenv').config({ path: __dirname + '/../../.env' }); | ||
const { Vonage } = require('@vonage/server-sdk'); | ||
const { Channels } = require('@vonage/messages'); | ||
|
||
const VONAGE_APPLICATION_ID = process.env.VONAGE_APPLICATION_ID; | ||
const VONAGE_PRIVATE_KEY = process.env.VONAGE_PRIVATE_KEY; | ||
const MESSENGER_RECIPIENT_ID = process.env.MESSENGER_RECIPIENT_ID; | ||
const MESSENGER_SENDER_ID = process.env.MESSENGER_SENDER_ID; | ||
const MESSAGES_IMAGE_URL = process.env.MESSAGES_IMAGE_URL; | ||
const MESSAGES_API_URL = process.env.MESSAGES_API_URL; | ||
|
||
const FB_RECIPIENT_ID = process.env.FB_RECIPIENT_ID; | ||
const FB_SENDER_ID = process.env.FB_SENDER_ID; | ||
const IMAGE_URL = process.env.IMAGE_URL; | ||
|
||
const { Vonage } = require('@vonage/server-sdk'); | ||
const { MessengerImage } = require('@vonage/messages'); | ||
|
||
const vonage = new Vonage({ | ||
applicationId: VONAGE_APPLICATION_ID, | ||
privateKey: VONAGE_PRIVATE_KEY, | ||
}); | ||
/** | ||
* It is best to send messages using JWT instead of basic auth. If you leave out | ||
* apiKey and apiSecret, the messages SDK will send requests using JWT tokens | ||
* | ||
* @link https://developer.vonage.com/en/messages/technical-details#authentication | ||
*/ | ||
const vonage = new Vonage( | ||
{ | ||
applicationId: VONAGE_APPLICATION_ID, | ||
privateKey: VONAGE_PRIVATE_KEY, | ||
}, | ||
{ | ||
...(MESSAGES_API_URL ? {apiHost: MESSAGES_API_URL} : {}), | ||
}, | ||
); | ||
|
||
vonage.messages.send( | ||
new MessengerImage({ | ||
image: { | ||
url: IMAGE_URL, | ||
}, | ||
to: FB_RECIPIENT_ID, | ||
from: FB_SENDER_ID, | ||
}), | ||
) | ||
.then(({ messageUUID}) => console.log(messageUUID)) | ||
vonage.messages.send({ | ||
messageType: 'image', | ||
channel: Channels.MESSENGER, | ||
image: { | ||
url: MESSAGES_IMAGE_URL, | ||
}, | ||
to: MESSENGER_RECIPIENT_ID, | ||
from: MESSENGER_SENDER_ID, | ||
}) | ||
.then(({ messageUUID }) => console.log(messageUUID)) | ||
.catch((error) => console.error(error)); |
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 |
---|---|---|
@@ -1,25 +1,35 @@ | ||
require('dotenv').config({ path: __dirname + '/../../.env' }); | ||
const { Vonage } = require('@vonage/server-sdk'); | ||
const { Channels } = require('@vonage/messages'); | ||
|
||
const VONAGE_APPLICATION_ID = process.env.VONAGE_APPLICATION_ID; | ||
const VONAGE_PRIVATE_KEY = process.env.VONAGE_PRIVATE_KEY; | ||
const MESSENGER_RECIPIENT_ID = process.env.MESSENGER_RECIPIENT_ID; | ||
const MESSENGER_SENDER_ID = process.env.MESSENGER_SENDER_ID; | ||
const MESSAGES_API_URL = process.env.MESSAGES_API_URL; | ||
|
||
const FB_RECIPIENT_ID = process.env.FB_RECIPIENT_ID; | ||
const FB_SENDER_ID = process.env.FB_SENDER_ID; | ||
|
||
const { Vonage } = require('@vonage/server-sdk'); | ||
const { MessengerText } = require('@vonage/messages'); | ||
|
||
const vonage = new Vonage({ | ||
applicationId: VONAGE_APPLICATION_ID, | ||
privateKey: VONAGE_PRIVATE_KEY, | ||
}); | ||
/** | ||
* It is best to send messages using JWT instead of basic auth. If you leave out | ||
* apiKey and apiSecret, the messages SDK will send requests using JWT tokens | ||
* | ||
* @link https://developer.vonage.com/en/messages/technical-details#authentication | ||
*/ | ||
const vonage = new Vonage( | ||
{ | ||
applicationId: VONAGE_APPLICATION_ID, | ||
privateKey: VONAGE_PRIVATE_KEY, | ||
}, | ||
{ | ||
...(MESSAGES_API_URL ? {apiHost: MESSAGES_API_URL} : {}), | ||
}, | ||
); | ||
|
||
vonage.messages.send( | ||
new MessengerText({ | ||
text: 'This is a Facebook Messenger text message sent using the Messages API', | ||
to: FB_RECIPIENT_ID, | ||
from: FB_SENDER_ID, | ||
}), | ||
) | ||
.then(({ messageUUID}) => console.log(messageUUID)) | ||
vonage.messages.send({ | ||
messageType: 'text', | ||
channel: Channels.MESSENGER, | ||
text: 'This is a Facebook Messenger text message sent using the Messages API', | ||
to: MESSENGER_RECIPIENT_ID, | ||
from: MESSENGER_SENDER_ID, | ||
}) | ||
.then(({ messageUUID }) => console.log(messageUUID)) | ||
.catch((error) => console.error(error)); |
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 |
---|---|---|
@@ -1,28 +1,38 @@ | ||
require('dotenv').config({ path: __dirname + '/../../.env' }); | ||
const { Vonage } = require('@vonage/server-sdk'); | ||
const { Channels } = require('@vonage/messages'); | ||
|
||
const VONAGE_APPLICATION_ID = process.env.VONAGE_APPLICATION_ID; | ||
const VONAGE_PRIVATE_KEY = process.env.VONAGE_PRIVATE_KEY; | ||
const MESSENGER_RECIPIENT_ID = process.env.MESSENGER_RECIPIENT_ID; | ||
const MESSENGER_SENDER_ID = process.env.MESSENGER_SENDER_ID; | ||
const MESSAGES_VIDEO_URL = process.env.MESSAGES_VIDEO_URL; | ||
const MESSAGES_API_URL = process.env.MESSAGES_API_URL; | ||
|
||
const FB_RECIPIENT_ID = process.env.FB_RECIPIENT_ID; | ||
const FB_SENDER_ID = process.env.FB_SENDER_ID; | ||
const VIDEO_URL = process.env.VIDEO_URL; | ||
|
||
const { Vonage } = require('@vonage/server-sdk'); | ||
const { MessengerVideo } = require('@vonage/messages'); | ||
|
||
const vonage = new Vonage({ | ||
applicationId: VONAGE_APPLICATION_ID, | ||
privateKey: VONAGE_PRIVATE_KEY, | ||
}); | ||
/** | ||
* It is best to send messages using JWT instead of basic auth. If you leave out | ||
* apiKey and apiSecret, the messages SDK will send requests using JWT tokens | ||
* | ||
* @link https://developer.vonage.com/en/messages/technical-details#authentication | ||
*/ | ||
const vonage = new Vonage( | ||
{ | ||
applicationId: VONAGE_APPLICATION_ID, | ||
privateKey: VONAGE_PRIVATE_KEY, | ||
}, | ||
{ | ||
...(MESSAGES_API_URL ? {apiHost: MESSAGES_API_URL} : {}), | ||
}, | ||
); | ||
|
||
vonage.messages.send( | ||
new MessengerVideo({ | ||
video: { | ||
url: VIDEO_URL, | ||
}, | ||
to: FB_RECIPIENT_ID, | ||
from: FB_SENDER_ID, | ||
}), | ||
) | ||
.then(({ messageUUID}) => console.log(messageUUID)) | ||
vonage.messages.send({ | ||
messageType: 'video', | ||
channel: Channels.MESSENGER, | ||
video: { | ||
url: MESSAGES_VIDEO_URL, | ||
}, | ||
to: MESSENGER_RECIPIENT_ID, | ||
from: MESSENGER_SENDER_ID, | ||
}) | ||
.then(({ messageUUID }) => console.log(messageUUID)) | ||
.catch((error) => console.error(error)); |
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,38 @@ | ||
require('dotenv').config({ path: __dirname + '/../.env' }); | ||
const { Vonage } = require('@vonage/server-sdk'); | ||
const { Channels } = require('@vonage/messages'); | ||
|
||
const VONAGE_APPLICATION_ID = process.env.VONAGE_APPLICATION_ID; | ||
const VONAGE_PRIVATE_KEY = process.env.VONAGE_PRIVATE_KEY; | ||
const MESSAGES_TO_NUMBER = process.env.MESSAGES_TO_NUMBER; | ||
const MMS_SEENDER_ID = process.env.MMS_SEENDER_ID; | ||
const MESSAGES_AUDIO_URL = process.env.MESSAGES_AUDIO_URL; | ||
const MESSAGES_API_URL = process.env.MESSAGES_API_URL; | ||
|
||
/** | ||
* It is best to send messages using JWT instead of basic auth. If you leave out | ||
* apiKey and apiSecret, the messages SDK will send requests using JWT tokens | ||
* | ||
* @link https://developer.vonage.com/en/messages/technical-details#authentication | ||
*/ | ||
const vonage = new Vonage( | ||
{ | ||
applicationId: VONAGE_APPLICATION_ID, | ||
privateKey: VONAGE_PRIVATE_KEY, | ||
}, | ||
{ | ||
...(MESSAGES_API_URL ? {apiHost: MESSAGES_API_URL} : {}), | ||
}, | ||
); | ||
|
||
vonage.messages.send({ | ||
messageType: 'audio', | ||
channel: Channels.MMS, | ||
audio:{ | ||
url: MESSAGES_AUDIO_URL, | ||
}, | ||
to: MESSAGES_TO_NUMBER, | ||
from: MMS_SEENDER_ID, | ||
}) | ||
.then(({ messageUUID }) => console.log(messageUUID)) | ||
.catch((error) => console.error(error)); |
Oops, something went wrong.