-
Notifications
You must be signed in to change notification settings - Fork 346
Repo now out of date #478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dooley1001
wants to merge
13
commits into
twilio-labs:main
Choose a base branch
from
dooley1001:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Repo now out of date #478
Changes from 6 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6969139
Added forwarding MMS to sendgrid
dooley1001 8ae6c03
Update README.md
dooley1001 4eab40e
Update README.md
dooley1001 ccf71b8
Update README.md
dooley1001 ecb3375
Update README.md
dooley1001 6680878
Update README.md
dooley1001 9a02225
Update forward-mms-sendgrid.js
dooley1001 a471857
Update README.md
dooley1001 5f74ce4
Update forward-mms-sendgrid.js
dooley1001 4f87ee5
Update README.md
dooley1001 6043371
Removed "warning" from README.md
dooley1001 3a8c2c4
Added info for attention at the start of README.md
dooley1001 01586e0
Removed warning README.md
dooley1001 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
56 changes: 56 additions & 0 deletions
56
forward-message-sendgrid/functions/forward-mms-sendgrid.js
This file contains hidden or 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,56 @@ | ||
| const got = require('got'); | ||
| const request = require('request-promise-native'); | ||
|
|
||
| exports.handler = function(context, event, callback) { | ||
| imagePath = event.MediaUrl0; | ||
|
|
||
| //read in the image here: | ||
| request({ | ||
| url: imagePath, | ||
| method: 'GET', | ||
| encoding: null | ||
| }) | ||
| .then(result => { | ||
|
|
||
| let imageBuffer = Buffer.from(result); | ||
| let imageBase64 = imageBuffer.toString('base64'); | ||
|
|
||
| //now create the email message | ||
| const msg = { | ||
| personalizations: [{ to: [{ email: context.TO_EMAIL_ADDRESS }] }], | ||
| from: { email: context.FROM_EMAIL_ADDRESS }, | ||
| subject: `New SMS message from: ${event.From}`, | ||
dooley1001 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| content: [ | ||
| { | ||
| type: 'text/plain', | ||
| value: event.Body | ||
| } | ||
| ], | ||
| attachments: [ | ||
| { | ||
| content: imageBase64, | ||
| filename: "owl.png", | ||
| type: "image/png", | ||
| disposition: "attachment", | ||
| content_id: "my_image" | ||
| } | ||
| ] | ||
| }; | ||
|
|
||
| //send mail | ||
| got.post('https://api.sendgrid.com/v3/mail/send', { | ||
| headers: { | ||
| Authorization: `Bearer ${context.SENDGRID_API_KEY}`, | ||
| 'Content-Type': 'application/json' | ||
| }, | ||
| body: JSON.stringify(msg) | ||
| }) | ||
| .then(response => { | ||
| let twiml = new Twilio.twiml.MessagingResponse(); | ||
| callback(null, twiml); | ||
| }) | ||
| .catch(err => { | ||
| callback(err); | ||
| }); | ||
| }); | ||
| }; | ||
dooley1001 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.