https://github.com/danieldacosta/lambda-messaging
Lambda that sends sms or email to user.
https://github.com/danieldacosta/lambda-messaging
Last synced: 29 days ago
JSON representation
Lambda that sends sms or email to user.
- Host: GitHub
- URL: https://github.com/danieldacosta/lambda-messaging
- Owner: DanielDaCosta
- License: apache-2.0
- Created: 2020-08-28T23:01:47.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-08-30T21:43:19.000Z (almost 6 years ago)
- Last Synced: 2025-02-28T11:30:47.741Z (over 1 year ago)
- Language: Python
- Size: 1.43 MB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Lambda Messaging
Lambda that sends sms or email to user. It receives an array of dictionaries containing
phone_number or email and message contents.
Input:
```
{
"data": {
[
{
'phone_number': '+552199999999',
'message': 'Bom dia!'
},
{
'email': 'test@gmail.com',
'message': 'Bom tarde!'
}
]
}
}
```
# Usage
Example of usage.
Lambda *asynchronous invocation* is preferable
```
import json
import boto3
from config import MS_MESSAGING
# MS_MESSAGING -> MS_MESSAGING ARN
def send_sms(messages_array):
"""Send sms
Args:
phone_number (string): the phone number that will receive the sms
body_message (string): the message
"""
client = boto3.client('lambda')
payload = {
"data": messages_array
}
client.invoke(
FunctionName=MS_MESSAGING,
InvocationType='Event',
Payload=json.dumps(payload),
LogType='None'
)
```