diff --git a/forward-message-sendgrid/.env b/forward-message-sendgrid/.env deleted file mode 100644 index 517d654c..00000000 --- a/forward-message-sendgrid/.env +++ /dev/null @@ -1,19 +0,0 @@ -# description: Your SendGrid API key -# format: secret -# link: https://sendgrid.com/docs/ui/account-and-settings/api-keys/ -# required: true -SENDGRID_API_KEY= - -# description: Messages sent to your Twilio number will be forwarded to this email address -# format: email -# required: true -TO_EMAIL_ADDRESS= - -# description: The email address that SendGrid should send the email from -# format: email -# required: true -FROM_EMAIL_ADDRESS= - -# description: The path to the webhook -# configurable: false -TWILIO_SMS_WEBHOOK_URL=/forward-message-sendgrid \ No newline at end of file diff --git a/forward-message-sendgrid/README.md b/forward-message-sendgrid/README.md deleted file mode 100644 index ee6e3d58..00000000 --- a/forward-message-sendgrid/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# Forward SMS message as an email (SendGrid) - -The SendGrid Function will forward incoming SMS messages to an email address using the [SendGrid API](https://sendgrid.com/). - -You will need a SendGrid account and an [API key](https://app.sendgrid.com/settings/api_keys) to use this Function. - -### Environment Variables - -This Function expects three environment variables to be set. - -| Variable | Meaning | -| :------------------- | :--------------------------------------------------------- | -| `SENDGRID_API_KEY` | Your SendGrid API key | -| `TO_EMAIL_ADDRESS` | The email address to forward the message to | -| `FROM_EMAIL_ADDRESS` | The email address that SendGrid should send the email from | - -### Dependencies - -This Function depends on one npm module. You should add the following dependencies in your [Functions configuration page](https://www.twilio.com/console/runtime/functions/configure). - -| Dependency | Version | -| :--------- | :------ | -| `got` | 6.7.1 | - -### Parameters - -This Function expects the incoming request to be a messaging webhook. The parameters that will be used are `From` and `Body`. diff --git a/forward-message-sendgrid/assets/index.html b/forward-message-sendgrid/assets/index.html deleted file mode 100644 index b6200deb..00000000 --- a/forward-message-sendgrid/assets/index.html +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - Get started with your Twilio Functions! - - - - - - - -
-
- - -
-
-
-
-

- -
-

Welcome!

-

Your live application with Twilio is ready to use!

-
-

-
-

Get started with your application

-

- Follow these steps to try out your new app: -

-

- This app forwards SMS messages sent to your Twilio phone number to the specified email - address using - SendGrid. -

-
    -
  1. Text any message to your Twilio phone number
  2. -
  3. - You should receive an email with the contents of the SMS in the email specified in - TO_EMAIL_ADDRESS -
  4. -
-
-
- -
-
-

Troubleshooting

-
    -
  • - Check the - - phone number configuration - - and make sure the Twilio phone number you want for your app has a SMS webhook - configured to point at the following URL -
    - - -
    -
  • -
-
-
-
- - - diff --git a/forward-message-sendgrid/changelog.md b/forward-message-sendgrid/changelog.md deleted file mode 100644 index 3982d461..00000000 --- a/forward-message-sendgrid/changelog.md +++ /dev/null @@ -1,8 +0,0 @@ -# Changelog - -## [Unreleased] - -## [1.0.0] -### Added -- Initial release. - diff --git a/forward-message-sendgrid/functions/forward-message-sendgrid.protected.js b/forward-message-sendgrid/functions/forward-message-sendgrid.protected.js deleted file mode 100644 index 321b0a62..00000000 --- a/forward-message-sendgrid/functions/forward-message-sendgrid.protected.js +++ /dev/null @@ -1,31 +0,0 @@ -const got = require('got'); - -exports.handler = function (context, event, callback) { - const requestBody = { - personalizations: [{ to: [{ email: context.TO_EMAIL_ADDRESS }] }], - from: { email: context.FROM_EMAIL_ADDRESS }, - subject: `New SMS message from: ${event.From}`, - content: [ - { - type: 'text/plain', - value: event.Body, - }, - ], - }; - - got - .post('https://api.sendgrid.com/v3/mail/send', { - headers: { - Authorization: `Bearer ${context.SENDGRID_API_KEY}`, - 'Content-Type': 'application/json', - }, - body: JSON.stringify(requestBody), - }) - .then((_response) => { - const twiml = new Twilio.twiml.MessagingResponse(); - callback(null, twiml); - }) - .catch((err) => { - callback(err); - }); -}; diff --git a/forward-message-sendgrid/package.json b/forward-message-sendgrid/package.json deleted file mode 100644 index dcb269f8..00000000 --- a/forward-message-sendgrid/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": "1.0.0", - "private": true, - "dependencies": { - "got": "^6.7.1" - } -} diff --git a/forward-message-sendgrid/tests/forward-message-sendgrid.test.js b/forward-message-sendgrid/tests/forward-message-sendgrid.test.js deleted file mode 100644 index bafe9fdd..00000000 --- a/forward-message-sendgrid/tests/forward-message-sendgrid.test.js +++ /dev/null @@ -1,44 +0,0 @@ -const helpers = require('../../test/test-helper'); - -const got = jest.mock('got'); -const sendGrid = - require('../functions/forward-message-sendgrid.protected').handler; -const Twilio = require('twilio'); - -const context = { - SENDGRID_API_KEY: 'APIKEY', - TO_EMAIL_ADDRESS: 'test_to@example.com', - FROM_EMAIL_ADDRESS: 'test_from@example.com', -}; -const event = { - Body: 'Hello', - From: 'ExternalNumber', -}; - -beforeAll(() => { - helpers.setup(context); -}); - -afterAll(() => { - helpers.teardown(); -}); - -test('returns an TwiML MessagingResponse', (done) => { - const callback = (_err, result) => { - expect(result).toBeInstanceOf(Twilio.twiml.MessagingResponse); - done(); - }; - - sendGrid(context, event, callback); -}); - -test('returns an error when the external request fails', (done) => { - const callback = (err, _result) => { - expect(err).toBeInstanceOf(Error); - done(); - }; - - got.shouldSucceed = false; - - sendGrid(context, event, callback); -}); diff --git a/forward-message-sparkpost/.env b/forward-message-sparkpost/.env deleted file mode 100644 index 6c60d8cd..00000000 --- a/forward-message-sparkpost/.env +++ /dev/null @@ -1,19 +0,0 @@ -# description: Your SparkPost API key -# format: secret -# link: https://www.sparkpost.com/docs/getting-started/create-api-keys/ -# required: true -SPARKPOST_API_KEY= - -# description: Messages sent to your Twilio number will be forwarded to this email address -# format: email -# required: true -TO_EMAIL_ADDRESS= - -# description: The email address that SparkPost should send the email from -# format: email -# required: true -FROM_EMAIL_ADDRESS= - -# description: The path to the webhook -# configurable: false -TWILIO_SMS_WEBHOOK_URL=/forward-message-sparkpost \ No newline at end of file diff --git a/forward-message-sparkpost/README.md b/forward-message-sparkpost/README.md deleted file mode 100644 index bce00bd3..00000000 --- a/forward-message-sparkpost/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# Forward SMS message as an email (Sparkpost) - -This Function will forward incoming SMS messages to an email address using the [SparkPost API](https://www.sparkpost.com/). - -You will need a SparkPost account and an [API key](https://app.sparkpost.com/account/credentials) to use this Function. - -### The SparkPost Sandbox - -If you are testing out with SparkPost you can [use their sandbox domain to send test emails](https://developers.sparkpost.com/api/transmissions/#header-the-sandbox-domain). To do so you should set your `FROM_EMAIL_ADDRESS` to "anything@sparkpostbox.com" and set `options.sandbox` to `true`. - -This code example includes the `sandbox` option. Ensure you set it to `false` or remove it when you change to use your own domain. - -### Environment Variables - -This Function expects three environment variables to be set. - -| Variable | Meaning | -| :------------------- | :---------------------------------------------------------- | -| `SPARKPOST_API_KEY` | Your SparkPost API key | -| `TO_EMAIL_ADDRESS` | The email address to forward the message to | -| `FROM_EMAIL_ADDRESS` | The email address that SparkPost should send the email from | - -### Dependencies - -This Function depends on one npm module. You should add the following dependencies in your [Functions configuration page](https://www.twilio.com/console/runtime/functions/configure). - -| Dependency | Version | -| :--------- | :------ | -| `got` | 6.7.1 | diff --git a/forward-message-sparkpost/assets/index.html b/forward-message-sparkpost/assets/index.html deleted file mode 100644 index c4dda4df..00000000 --- a/forward-message-sparkpost/assets/index.html +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - Get started with your Twilio Functions! - - - - - - - -
-
- - -
-
-
-
-

- -
-

Welcome!

-

Your live application with Twilio is ready to use!

-
-

-
-

Get started with your application

-

- Follow these steps to try out your new app: -

-

- This app forwards SMS messages sent to your Twilio phone number to the specified email address - using SparkPost. -

-
    -
  1. Text any message to your Twilio phone number
  2. -
  3. - You should receive an email with the contents of the SMS at the email address specified in - TO_EMAIL_ADDRESS -
  4. -
-
-
- -
-
-

Troubleshooting

-
    -
  • - Check the - - phone number configuration - - and make sure the Twilio phone number you want for your app has a SMS webhook - configured to point at the following URL -
    - - -
    -
  • -
-
-
-
- - - diff --git a/forward-message-sparkpost/changelog.md b/forward-message-sparkpost/changelog.md deleted file mode 100644 index 3982d461..00000000 --- a/forward-message-sparkpost/changelog.md +++ /dev/null @@ -1,8 +0,0 @@ -# Changelog - -## [Unreleased] - -## [1.0.0] -### Added -- Initial release. - diff --git a/forward-message-sparkpost/functions/forward-message-sparkpost.protected.js b/forward-message-sparkpost/functions/forward-message-sparkpost.protected.js deleted file mode 100644 index 39d1050b..00000000 --- a/forward-message-sparkpost/functions/forward-message-sparkpost.protected.js +++ /dev/null @@ -1,31 +0,0 @@ -const got = require('got'); - -exports.handler = function (context, event, callback) { - const requestBody = { - content: { - from: context.FROM_EMAIL_ADDRESS, - subject: `New SMS message from: ${event.From}`, - text: event.Body, - }, - recipients: [{ address: { email: context.TO_EMAIL_ADDRESS } }], - options: { - sandbox: true, - }, - }; - - got - .post('https://api.sparkpost.com/api/v1/transmissions', { - headers: { - Authorization: `${context.SPARKPOST_API_KEY}`, - 'Content-Type': 'application/json', - }, - body: JSON.stringify(requestBody), - }) - .then((response) => { - const twiml = new Twilio.twiml.MessagingResponse(); - callback(null, twiml); - }) - .catch((err) => { - callback(err); - }); -}; diff --git a/forward-message-sparkpost/package.json b/forward-message-sparkpost/package.json deleted file mode 100644 index dcb269f8..00000000 --- a/forward-message-sparkpost/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": "1.0.0", - "private": true, - "dependencies": { - "got": "^6.7.1" - } -} diff --git a/forward-message-sparkpost/tests/forward-message-sparkpost.test.js b/forward-message-sparkpost/tests/forward-message-sparkpost.test.js deleted file mode 100644 index 8e285693..00000000 --- a/forward-message-sparkpost/tests/forward-message-sparkpost.test.js +++ /dev/null @@ -1,44 +0,0 @@ -const helpers = require('../../test/test-helper'); - -const got = jest.mock('got'); -const sparkPost = - require('../functions/forward-message-sparkpost.protected').handler; -const Twilio = require('twilio'); - -const context = { - SPARKPOST_API_KEY: 'APIKEY', - TO_EMAIL_ADDRESS: 'test_to@example.com', - FROM_EMAIL_ADDRESS: 'test_from@example.com', -}; -const event = { - Body: 'Hello', - From: 'ExternalNumber', -}; - -beforeAll(() => { - helpers.setup(context); -}); - -afterAll(() => { - helpers.teardown(); -}); - -test('returns an TwiML MessagingResponse', (done) => { - const callback = (_err, result) => { - expect(result).toBeInstanceOf(Twilio.twiml.MessagingResponse); - done(); - }; - - sparkPost(context, event, callback); -}); - -test('returns an error when the external request fails', (done) => { - const callback = (err, _result) => { - expect(err).toBeInstanceOf(Error); - done(); - }; - - got.shouldSucceed = false; - - sparkPost(context, event, callback); -}); diff --git a/package.json b/package.json index 7e6fe088..2e06b6b8 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,6 @@ "eslint-config-twilio": "^2.0.0", "eslint-plugin-prettier": "^5.1.3", "get-port": "^7.1.0", - "got": "^14.3.0", "husky": "^9.0.11", "inquirer": "^8.2.4", "jest-cli": "^29.7.0", @@ -89,8 +88,6 @@ "forward-call", "forward-message", "forward-message-mailgun", - "forward-message-sendgrid", - "forward-message-sparkpost", "frontline-quickstart", "funlet-call-me", "funlet-echo",