1

The following code works to send a message but when it arrives, it displays the text 'VERIFY' for a sender id. How do I specific a sender ID? I think it's done with the message attributes but I cannot figure out the syntax.

session = boto3.session.Session(profile_name='Credentials',region_name='us-east-1')
theMessage='Now is the time for all good people to come to the aid of their party'
senderID='Godzilla'
snsclient = session.client('sns')
response = snsclient.publish(PhoneNumber='+84932575571', Message=theMessage)
pp = pprint.PrettyPrinter(indent=4)
print(pp.pprint(response))
xaxxon
  • 19,189
  • 5
  • 50
  • 80
Dennis M. Gray
  • 332
  • 1
  • 3
  • 17

1 Answers1

8

Add a third parameter MessageAttributes to the publish method.

snsclient.publish(PhoneNumber='+84932575571', Message=theMessage,MessageAttributes={
'AWS.SNS.SMS.SenderID': {
  'DataType': 'String',
  'StringValue': 'Godzilla'   
}})

The sender id is not supported in many countries. see AWS SNS SMS SenderId Supported Countries

Vaisakh PS
  • 1,181
  • 2
  • 10
  • 19