简体   繁体   中英

Has anyone built an integration with any SMS Receivers?

I want to be able to send a text message to some number and then (upon receiving the text) basically just send a post request off to a different service after receiving the text. Does anyone know of a service I could use to set this up? Would like for it to be as fast as possible

Here's a summary of the steps to setup a sample app:

  1. Navigate to Amazon SNS Service → Topics
  2. Enter Name and create a new Topic
  3. For the newly created topic, create a subscription where the Protocol is AWS Lambda (see image1 below)
  4. Navigate to Amazon Pinpoint Service, create new Pinpoint application
  5. Enable SMS & voice feature for this Pinpoint application
  6. Get a new Long Code (long code price is $1/month)
  7. For the long code, Enable two-way SMS , select the Choose an existing SNS topic option and select the SNS topic created in Step 2 above (see image2 below)
  8. Finally, now you can send a message to that phone number from your phone and it will trigger your lambda function. In your lambda function, you can send a POST request to a different service or do whatever else. You can also respond back to the user's message - see example below.

Here's an example of how to send a message using Amazon Pinpoint in Java:

public void sendSMS(String pinpointPhoneNumber, String userPhoneNumber, String messageContent) {
    // define who the message is going to and via what platform
    Map<String, AddressConfiguration> addressMap = new HashMap<>();
    addressMap.put(userPhoneNumber, new AddressConfiguration().withChannelType(ChannelType.SMS));

    SMSMessage smsMessage = new SMSMessage();
    smsMessage.setOriginationNumber(pinpointPhoneNumber);
    smsMessage.setMessageType(MessageType.TRANSACTIONAL);
    smsMessage.setBody(messageContent);

    // add sms message to the direct message config
    // this can have many other types of messages
    DirectMessageConfiguration directMessageConfiguration = new DirectMessageConfiguration()
        .withSMSMessage(smsMessage);

    // put the phone numbers and all messages in here
    MessageRequest messageRequest = new MessageRequest()
        .withAddresses(addressMap)
        .withMessageConfiguration(directMessageConfiguration);

    // create send request
    SendMessagesRequest sendMessagesRequest = new SendMessagesRequest()
        .withApplicationId("put-pinpoint-app-id-here")
        .withMessageRequest(messageRequest);

    // send the message
    AmazonPinpoint pinpointClient = AmazonPinpointClientBuilder.standard().build();
    SendMessagesResult sendMessagesResult = pinpointClient.sendMessages(sendMessagesRequest);
    MessageResponse messageResponse = sendMessagesResult.getMessageResponse();
}

创建 Lambda 函数的 SNS 主题订阅 Amazon Pinpoint 的双向 SMS 配置

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM