AWS SNS 發送一封最簡單的簡訊

Veck
3 min readSep 28, 2017

--

  1. 點選左邊選單的『Text message (SMS)』,點選最下面的『Publish text message』

2. 輸入 (Mobile) Number 和 Message (最多 70 個字),Message type 先預設,Sender ID 先留白

3. 按下『Send text message』後就送出了!

  • 不需要申請一支門號,也不需要預繳費用就可以發送簡訊!
  • 速度超快,送出後半秒鐘就收到了!

Message Type

  • Promotional —不是那麼重要的訊息,例如廣告簡訊,AWS 會最佳化簡訊內容來獲得較好的傳輸效率
  • Transactional —重要的訊息,例如與客戶交易相關的內容(one-time passcodes),AWS 會最佳化簡訊內容來達到較好的可靠度

Sender ID

The sender ID is displayed as the message sender on the receiving device. For example, you can use your business brand to make the message source easier to recognize.

根據說明,這個資料主要是用來顯示簡訊發送者是誰,如此一來收到簡訊就會顯示特定發送者,而非隨機號碼,但並非所有國家的簡訊接收都支援使用 Sender ID。

Support for sender IDs varies by country. For example, messages delivered to U.S. phone numbers will not display the sender ID. For the countries that support sender IDs, see Supported Regions and Countries.

If you do not specify a sender ID, the message will display a long code as the sender ID in supported countries. For countries that require an alphabetic sender ID, the message displays NOTICE as the sender ID.

This message-level sender ID overrides your default sender ID, which you set on the Text messaging preferences page.

SDK

前面是直接在 AWS SNS console 發送簡訊,而這裡展示的是透過 AWS SDK (Node.js) 來發送簡訊

const AWS = require('aws-sdk')const sns = new AWS.SNS({ region: 'ap-northeast-1' })var params = {Message: '這是透過 Node.js AWS SDK 發送的簡訊',PhoneNumber: '+88691********'}sns.publish(params, (err, data) => {if (err) console.log(err, err.stack)else         console.log(data)})

send

$ node test.js{ ResponseMetadata: { RequestId: '7a7eb765-5beb-582b-8f3f-e5233feb807e' },MessageId: '4b39898a-9e0f-522f-872b-dbccfa0f3a7a' }

Fee

查詢:https://aws.amazon.com/tw/sns/sms-pricing/

Taiwan

來比較一下 Twilio 和 nexmo

Twilio

nexmo

應該是 AWS SNS 明顯便宜一點,而且 Twilio 需要先購買一支 1 USD/month 的手機門號,nexmo 則是 € 0.0442 /month ( = 1.57210193 NTD/month)

Reference

http://docs.aws.amazon.com/sns/latest/dg/SMSMessages.html
http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SNS.html#publish-property
http://docs.aws.amazon.com/sns/latest/dg/sms_supported-countries.html

--

--

Responses (2)