Skip to content
Merged
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
3 changes: 1 addition & 2 deletions docs/templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ This is the list of Functions available in this repo:
* [Hello Messaging](https://github.com/twilio-labs/function-templates/blob/main/hello-messaging): Function to get you started with Twilio Prog. Messaging
* [Never gonna give you up](https://github.com/twilio-labs/function-templates/blob/main/never-gonna-give-you-up): Never gonna let you down. Plays a song to a phone call
* [Forward Call](https://github.com/twilio-labs/function-templates/blob/main/forward-call): Forwards an incoming call to another number
* [Forward Message](https://github.com/twilio-labs/function-templates/blob/main/forward-message): Forwards incoming messages to another number
* [Forward Message to Multiple Numbers](https://github.com/twilio-labs/function-templates/blob/main/forward-message-multiple): Forwards incoming messages to a set of numbers
* [Forward Message](https://github.com/twilio-labs/function-templates/blob/main/forward-message): Forwards incoming messages to another number or to a set of numbers
* [Forward Message to Email via SendGrid](https://github.com/twilio-labs/function-templates/blob/main/forward-message-sendgrid): Uses SendGrid to forward incoming messages via email
* [Voicemail](https://github.com/twilio-labs/function-templates/blob/main/voicemail): Forwards calls during business hours. Records messages otherwise.
* [Forward Message to Email via Sparkpost](https://github.com/twilio-labs/function-templates/blob/main/forward-message-sparkpost): Uses Sparkpost to forward incoming messages via email
Expand Down
32 changes: 5 additions & 27 deletions env-variables.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,35 +62,13 @@
}
],
"forward-message": [
{
"key": "MY_PHONE_NUMBER",
"required": true,
"format": "phone_number",
"description": "Messages sent to your Twilio number will get forwarded to this E.164-formatted phone number",
"link": "https://www.twilio.com/docs/glossary/what-e164",
"default": "+12223334444",
"configurable": true,
"contentKey": null
},
{
"key": "TWILIO_SMS_WEBHOOK_URL",
"required": true,
"format": "text",
"description": "The path to the webhook",
"link": null,
"default": "/forward-message",
"configurable": false,
"contentKey": null
}
],
"forward-message-multiple": [
{
"key": "FORWARDING_NUMBERS",
"required": true,
"format": "list(phone_number)",
"description": "A list of numbers in E.164 format you want to forward incoming messages to, separated by commas",
"link": null,
"default": "+12223334444,+491761234567",
"link": "https://www.twilio.com/docs/glossary/what-e164",
"default": "+12223334444,+12223335555",
"configurable": true,
"contentKey": null
},
Expand All @@ -100,7 +78,7 @@
"format": "text",
"description": "The path to the webhook",
"link": null,
"default": "/forward-message-multiple",
"default": "/forward-message",
"configurable": false,
"contentKey": null
}
Expand Down Expand Up @@ -472,7 +450,7 @@
"format": "phone_number",
"description": "A comma separated list of numbers in E.164 format that you want to dial in order",
"link": null,
"default": "+12223334444,+491761234567",
"default": "+12223334444,+12223335555",
"configurable": true,
"contentKey": null
},
Expand Down Expand Up @@ -1288,7 +1266,7 @@
"format": "phone_number",
"description": "A comma separated list of numbers in E.164 format that are allowed to trigger a broadcast",
"link": null,
"default": "+12223334444,+491761234567",
"default": "+12223334444,+12223335555",
"configurable": true,
"contentKey": null
},
Expand Down
8 changes: 0 additions & 8 deletions forward-message-multiple/.env

This file was deleted.

15 changes: 0 additions & 15 deletions forward-message-multiple/README.md

This file was deleted.

89 changes: 0 additions & 89 deletions forward-message-multiple/assets/index.html

This file was deleted.

8 changes: 0 additions & 8 deletions forward-message-multiple/changelog.md

This file was deleted.

This file was deleted.

5 changes: 0 additions & 5 deletions forward-message-multiple/package.json

This file was deleted.

52 changes: 0 additions & 52 deletions forward-message-multiple/tests/forward-message-multiple.test.js

This file was deleted.

6 changes: 3 additions & 3 deletions forward-message/.env
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# description: Messages sent to your Twilio number will get forwarded to this E.164-formatted phone number
# format: phone_number
# description: A list of numbers in E.164 format you want to forward incoming messages to, separated by commas
# format: list(phone_number)
# required: true
# link: https://www.twilio.com/docs/glossary/what-e164
MY_PHONE_NUMBER=+12223334444
FORWARDING_NUMBERS=+12223334444,+491761234567
Copy link
Contributor

Choose a reason for hiding this comment

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

German number is still here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey all I'm going to go ahead and accept this one for now so we can get the basic update live with the maestro redeployment that is being scheduled for tonight, and we can fix the forwarding number with the next update.


# description: The path to the webhook
# configurable: false
Expand Down
4 changes: 2 additions & 2 deletions forward-message/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Forward Message

This Function in `forward-message.js` will return the TwiML required to forward an incoming SMS message to a number that is set in the environment variables.
This Function in `forward-message.js` returns the TwiML required to forward an incoming SMS message to a single number or each number in a comma-separated list set in the environment variables.

### Environment variables

This Function expects one environment variable to be set.

| Variable | Meaning |
| :---------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `MY_PHONE_NUMBER` | The number you want to forward incoming messages to [in E.164 format](https://support.twilio.com/hc/en-us/articles/223183008-Formatting-International-Phone-Numbers) |
| `FORWARDING_NUMBERS` | A list of numbers [in E.164 format](https://support.twilio.com/hc/en-us/articles/223183008-Formatting-International-Phone-Numbers) you want to forward incoming messages to, separated by commas |

### Parameters

Expand Down
12 changes: 6 additions & 6 deletions forward-message/assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ <h1>
</h1>
<section>
<h2>Get started with your application</h2>
<p>
Follow these steps to try out your new app:
</p>
<p>
This app will return the
<a href="https://www.twilio.com/docs/sms/twiml" target="_blank" rel="noopener">TwiML</a>
required to forward an incoming SMS message to the number that is set in the environment
variables.
required to forward an incoming SMS message to each number in the comma separated list of
numbers set in the environment variables.
</p>
<p>
Follow these steps to try out your new app:
</p>
<ol class="steps">
<li>Text any message to your Twilio phone number</li>
<li>Receive the response message from Twilio</li>
<li>Every phone number you specified should receive the response message from Twilio</li>
</ol>
</section>
<section>
Expand Down
6 changes: 4 additions & 2 deletions forward-message/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

## [Unreleased]

## [1.0.0]
## [1.0.1]
### Added
- Initial release.
- Updated and merged templates for single number and multi-number forwarding.
- Added code comments.
- Updated and added test cases.

36 changes: 32 additions & 4 deletions forward-message/functions/forward-message.protected.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,36 @@
/*
* Forward a Message to a Specified Number or List of Numbers
*
* Description: When your Twilio Phone Number associated with this function
* receives an SMS, it will forward the message to the phone number(s) listed
* in FORWARDING_NUMBERS specified in /.env. This will work whether a single
* number or multiple numbers are listed.
*
* Contents:
* 1. Main Handler
*/

/*
* 1. Main Handler
*
* This is the entry point to your Twilio Function,
* which will create a new MessagingResponse using TwiML
* and forward the incoming SMS to each number specified in
* the FORWARDING_NUMBERS environment variable.
*
* We then use the callback to return from your function
* with the TwiML MessagingResponse you defined earlier.
* In the callback, in non-error situations, the first
* parameter is null and the second parameter
* is the value you want to return.
*/

exports.handler = function (context, event, callback) {
const twiml = new Twilio.twiml.MessagingResponse();
twiml.message(
{ to: context.MY_PHONE_NUMBER },
`From: ${event.From}. Body: ${event.Body}`
);

context.FORWARDING_NUMBERS.split(/,\s?/).forEach((number) => {
twiml.message({ to: number }, `From: ${event.From}. Body: ${event.Body}`);
});

callback(null, twiml);
};
2 changes: 1 addition & 1 deletion forward-message/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.0.0",
"version": "1.0.1",
"private": true,
"dependencies": {}
}
Loading
Loading