Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions messages/mms/send-mms-content.ts
Original file line number Diff line number Diff line change
@@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;

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',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
messageType: 'image',
messageType: 'content',

channel: Channels.MMS,
content: [
{
type: 'image',
url: MESSAGES_IMAGE_URL,
},
{
type: 'file',
url: MESSAGES_FILE_URL,

}
],
to: MESSAGES_TO_NUMBER,
from: MMS_SEENDER_ID,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from: MMS_SEENDER_ID,
from: MMS_SENDER_ID,

})
.then(({ messageUUID }) => console.log(messageUUID))
.catch((error) => console.error(error));
39 changes: 39 additions & 0 deletions messages/mms/send-mms-file.js
Original file line number Diff line number Diff line change
@@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;

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',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
messageType: 'image',
messageType: 'file',

channel: Channels.MMS,
file: {
url: MESSAGES_FILE_URL,
},
to: MESSAGES_TO_NUMBER,
from: MMS_SEENDER_ID,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from: MMS_SEENDER_ID,
from: MMS_SENDER_ID,

})
.then(({ messageUUID }) => console.log(messageUUID))
.catch((error) => console.error(error));
37 changes: 37 additions & 0 deletions messages/mms/send-mms-text.js
Original file line number Diff line number Diff line change
@@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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');
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',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from: MMS_SEENDER_ID,
from: MMS_SENDER_ID,

})
.then(({ messageUUID }) => console.log(messageUUID))
.catch((error) => console.error(error));