in lambda/src/data_access/send_sms.py [0:0]
def send_sms(destination_number, message):
try:
response = pinpoint_client.send_messages(
ApplicationId=PINPOINT_PROJECT_ID,
MessageRequest={
'Addresses': {
destination_number: {
'ChannelType': 'SMS'
}
},
'MessageConfiguration': {
'SMSMessage': {
'Body': message,
'Keyword': PINPOINT_KEYWORD,
'MessageType': 'TRANSACTIONAL',
'OriginationNumber': PINPOINT_ORIGIN_NUMBER,
'SenderId': PINPOINT_SENDER_ID
}
}
}
)
except ClientError as e:
logger.error(f'Sending SMS to {destination_number} failed.')
logger.error(e.response['Error']['Message'])
else:
logger.info(f"Message sent success to {destination_number}!"
f" Message ID: {response['MessageResponse']['Result'][destination_number]['MessageId']}")