sending a text message with lambda using a database of phone numbers code example
Example: sending a text message with lambda using a database of phone numbers
import logging
import boto3
logger = logging.getLogger()
logger.setLevel(logging.INFO)
session = boto3.Session(
region_name="eu-west-1"
)
sns_client = session.client('sns')
def lambda_handler(event, context):
response = sns_client.publish(
PhoneNumber=event["phone_number"],
Message='Hi there! This is a test message sent with Amazon SNS',
MessageAttributes={
'AWS.SNS.SMS.SenderID': {
'DataType': 'String',
'StringValue': 'SENDERID'
},
'AWS.SNS.SMS.SMSType': {
'DataType': 'String',
'StringValue': 'Promotional'
}
}
)
logger.info(response)
return 'OK'