From 1a1e739c2eb415682170e3d9b6c197e0775a156a Mon Sep 17 00:00:00 2001 From: Chuck MANCHUCK Reeves Date: Mon, 7 Jul 2025 16:16:32 -0400 Subject: [PATCH 1/2] feat: added new mms examples --- messages/mms/send-mms-content.ts | 48 ++++++++++++++++++++++++++++++++ messages/mms/send-mms-file.js | 39 ++++++++++++++++++++++++++ messages/mms/send-mms-text.js | 37 ++++++++++++++++++++++++ 3 files changed, 124 insertions(+) create mode 100644 messages/mms/send-mms-content.ts create mode 100644 messages/mms/send-mms-file.js create mode 100644 messages/mms/send-mms-text.js diff --git a/messages/mms/send-mms-content.ts b/messages/mms/send-mms-content.ts new file mode 100644 index 0000000..489363f --- /dev/null +++ b/messages/mms/send-mms-content.ts @@ -0,0 +1,48 @@ +require('dotenv').config({ path: __dirname + '/../.env' }); + +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_IMAGE_URL = process.env.MESSAGES_IMAGE_URL; +const MESSAGES_FILE_URL = process.env.MESSAGES_FILE_URL; +const MESSAGES_API_URL = process.env.MESSAGES_API_URL; + +const { Channels, } = require('@vonage/messages'); +const { Vonage } = require('@vonage/server-sdk'); + +/** + * 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: 'image', + channel: Channels.MMS, + content: [ + { + type: 'image', + url: MESSAGES_IMAGE_URL, + }, + { + type: 'file', + url: MESSAGES_FILE_URL, + + } + ], + to: MESSAGES_TO_NUMBER, + from: MMS_SEENDER_ID, +}) + .then(({ messageUUID }) => console.log(messageUUID)) + .catch((error) => console.error(error)); diff --git a/messages/mms/send-mms-file.js b/messages/mms/send-mms-file.js new file mode 100644 index 0000000..f21d1d6 --- /dev/null +++ b/messages/mms/send-mms-file.js @@ -0,0 +1,39 @@ +require('dotenv').config({ path: __dirname + '/../.env' }); + +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_FILE_URL = process.env.MESSAGES_FILE_URL; +const MESSAGES_API_URL = process.env.MESSAGES_API_URL; + +const { Vonage } = require('@vonage/server-sdk'); +const { Channels } = require('@vonage/messages'); + +/** + * 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: 'image', + channel: Channels.MMS, + file: { + url: MESSAGES_FILE_URL, + }, + to: MESSAGES_TO_NUMBER, + from: MMS_SEENDER_ID, +}) + .then(({ messageUUID }) => console.log(messageUUID)) + .catch((error) => console.error(error)); diff --git a/messages/mms/send-mms-text.js b/messages/mms/send-mms-text.js new file mode 100644 index 0000000..b77f454 --- /dev/null +++ b/messages/mms/send-mms-text.js @@ -0,0 +1,37 @@ +require('dotenv').config({ path: __dirname + '/../.env' }); + +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_API_URL = process.env.MESSAGES_API_URL; + +const { Vonage } = require('@vonage/server-sdk'); +const { Channels } = require('@vonage/messages'); + +/** + * 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: 'image', + channel: Channels.MMS, + text: 'This is an RCS text message sent via the Vonage Messages API.', + to: MESSAGES_TO_NUMBER, + from: MMS_SEENDER_ID, +}) + .then(({ messageUUID }) => console.log(messageUUID)) + .catch((error) => console.error(error)); + From 488f8e5a8eff5ffcc34aadeaa9036c1b60007623 Mon Sep 17 00:00:00 2001 From: Chuck Reeves Date: Wed, 17 Sep 2025 13:57:37 -0400 Subject: [PATCH 2/2] chore: fixed typo in MMS_SENDER_ID Co-authored-by: Karl Lingiah --- messages/mms/send-mms-content.ts | 6 +++--- messages/mms/send-mms-file.js | 6 +++--- messages/mms/send-mms-text.js | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/messages/mms/send-mms-content.ts b/messages/mms/send-mms-content.ts index 489363f..b940c8b 100644 --- a/messages/mms/send-mms-content.ts +++ b/messages/mms/send-mms-content.ts @@ -3,7 +3,7 @@ require('dotenv').config({ path: __dirname + '/../.env' }); 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 MMS_SENDER_ID = process.env.MMS_SENDER_ID; const MESSAGES_IMAGE_URL = process.env.MESSAGES_IMAGE_URL; const MESSAGES_FILE_URL = process.env.MESSAGES_FILE_URL; const MESSAGES_API_URL = process.env.MESSAGES_API_URL; @@ -28,7 +28,7 @@ const vonage = new Vonage( ); vonage.messages.send({ - messageType: 'image', + messageType: 'content', channel: Channels.MMS, content: [ { @@ -42,7 +42,7 @@ vonage.messages.send({ } ], to: MESSAGES_TO_NUMBER, - from: MMS_SEENDER_ID, + from: MMS_SENDER_ID, }) .then(({ messageUUID }) => console.log(messageUUID)) .catch((error) => console.error(error)); diff --git a/messages/mms/send-mms-file.js b/messages/mms/send-mms-file.js index f21d1d6..d595bed 100644 --- a/messages/mms/send-mms-file.js +++ b/messages/mms/send-mms-file.js @@ -3,7 +3,7 @@ require('dotenv').config({ path: __dirname + '/../.env' }); 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 MMS_SENDER_ID = process.env.MMS_SENDER_ID; const MESSAGES_FILE_URL = process.env.MESSAGES_FILE_URL; const MESSAGES_API_URL = process.env.MESSAGES_API_URL; @@ -27,13 +27,13 @@ const vonage = new Vonage( ); vonage.messages.send({ - messageType: 'image', + messageType: 'file', channel: Channels.MMS, file: { url: MESSAGES_FILE_URL, }, to: MESSAGES_TO_NUMBER, - from: MMS_SEENDER_ID, + from: MMS_SENDER_ID, }) .then(({ messageUUID }) => console.log(messageUUID)) .catch((error) => console.error(error)); diff --git a/messages/mms/send-mms-text.js b/messages/mms/send-mms-text.js index b77f454..098aceb 100644 --- a/messages/mms/send-mms-text.js +++ b/messages/mms/send-mms-text.js @@ -3,7 +3,7 @@ require('dotenv').config({ path: __dirname + '/../.env' }); 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 MMS_SENDER_ID = process.env.MMS_SENDER_ID; const MESSAGES_API_URL = process.env.MESSAGES_API_URL; const { Vonage } = require('@vonage/server-sdk'); @@ -26,11 +26,11 @@ const vonage = new Vonage( ); vonage.messages.send({ - messageType: 'image', + messageType: 'text', channel: Channels.MMS, text: 'This is an RCS text message sent via the Vonage Messages API.', to: MESSAGES_TO_NUMBER, - from: MMS_SEENDER_ID, + from: MMS_SENDER_ID, }) .then(({ messageUUID }) => console.log(messageUUID)) .catch((error) => console.error(error));