1
votes

I would like to set AWS.SNS.SMS.SenderID when sending SMS via Amazon SNS.

This code successfully send message, but sender ID wan not MySenderID and instead phone number is shown.

@sns_client ||= Aws::SNS::Client.new(region: "ap-northeast-1", credentials: credentials)
@sns_client.publish(
  phone_number: "+81xxxxxxxxxx",
  message: message,
  message_attributes: {
    "AWS.SNS.SMS.SMSType" => { data_type: "String", string_value: "Transactional" },
    "AWS.SNS.SMS.SenderID" => { data_type: "String", string_value: "MySenderID" }
  }
)

Since I can successfully set sender ID via web console, there should be a way to set it programaticcally in Ruby.

How can I set senderID?

1

1 Answers

0
votes

Have a look at http://docs.aws.amazon.com/sdkforruby/api/Aws/SNS/Client.html#set_sms_attributes-instance_method

resp = client.set_sms_attributes({
  attributes: {
    "DefaultSenderID" => "Your ID",
  },
})