【问题标题】:Sending sms via amazon tollfree number using pinpoint Nodejs使用 pinpoint Nodejs 通过亚马逊免费电话号码发送短信
【发布时间】:2021-03-25 15:09:55
【问题描述】:

大家好,我正在尝试通过 nodejs 使用免费电话号码通过亚马逊 pinpoint 发送 SMS 消息。请注意,为了安全起见,此代码中的数字已更改。这是我的代码:

router.get("/send-text", async (req, res, next) => {
  try {
    const sender = "+18446850251";
    const destinationNumber = "+14325948991";
    const message = "HELLO from AWS";
    const applicationId = "myApplicationId";
    const messageType = "TRANSACTIONAL";
    AWS.config.update({ region: "us-east-1" });
    const pinpoint = new AWS.Pinpoint();
    const params = {
      ApplicationId: applicationId,
      MessageRequest: {
        Addresses: {
          [destinationNumber]: {
            BodyOverride: message,
            ChannelType: "SMS"
          }
        },
        MessageConfiguration: {
          SMSMessage: {
            Body: message,
            MessageType: messageType,
            OriginationNumber: sender
          }
        }
      }
    };
    const result = await pinpoint.sendMessages(params).promise();
    res.send(result);
  } catch (error) {
    console.log(error);
    next(error);
  }
});

运行此代码后,我得到以下响应:

{
MessageResponse: {
ApplicationId: "myApplicationId",
RequestId: "8beaebf0-f33a-42d3-bb88-1f3efcf493eb",
Result: {
+14325948991: {
DeliveryStatus: "PERMANENT_FAILURE",
StatusCode: 404,
StatusMessage: "Resource not found"
}
}
}
}

旁注:我这样做的原因是我收到了来自 AWS 的电子邮件,我的理解是我不能再通过应用程序通过 SNS 主题向某人(10 位长代码)发送短信,并且必须从 6 月 1 日开始,使用 10DLC 长代码或免费号码通过精确定位发送它们,对吗?

image of settings

【问题讨论】:

    标签: amazon-web-services sms aws-pinpoint


    【解决方案1】:

    如本 AWS 文档所述,您的假设是正确的:https://docs.aws.amazon.com/sns/latest/dg/channels-sms-awssupport-long-code.html

    我刚刚使用这些值进行了测试:

        String message = "This is a Pinpoint test"; 
        String appId = "2fdc4442c6a2483f85eaf7a9430xxxxx";
        String originationNumber = "+14387956xxx" ;
        String destinationNumber = "+18195765xxx" ; 
        System.out.println("Sending a message" );
    

    回复是:

    +18195765xxx:MessageResult(DeliveryStatus=SUCCESSFUL, MessageId=4eniddp3gqrsarku8q2i2vnqqo0v8eov0t1dhs80, StatusCode=200, StatusMessage=MessageId:

    app id 可以从 AWS 管理控制台获取:

    要获取原始编号 - 您在 AWS 控制台中请求代码并在您的应用程序逻辑中使用该代码:

    【讨论】:

    • 太棒了,仍然无法通过 pinpoint 发送消息。有什么想法吗?
    • 发送消息时,您需要一个有效的发起号码。你能确认这是正确的吗?
    • 我通过 pinpoint 注册了一个免费电话号码并将其复制并粘贴到 sender 变量中。所以是的,如果这就是你的意思,那么它是正确的。
    • 也检查您的应用程序 ID - 我刚刚测试过 - 请参阅上面的代码并得到 200 响应
    • 我可以看到代码 sn-p 吗?应用程序 ID 是您的项目名称旁边的项目 ID 在 pinpoint > 所有项目是否正确?
    【解决方案2】:

    SNS 消息未明确启用。请务必仔细检查此设置

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-06-15
      • 2013-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多