title: How to read incoming sms messages without sending an auto-response
body: <p>I want to read an incoming message from Twilio. I have set up the tunneling with ngrok as advised on their website.</p>
  
  <p>I am able to send the message using the following</p>
  
  <p><strong>SendMessage.java</strong></p>
  
  <pre><code>Twilio.init(SendAndReceiveController.ACCOUNT_SID, SendAndReceiveController.AUTH_TOKEN);
      Message message = Message.creator(new PhoneNumber(receiver),
              new PhoneNumber(sender),smsContent).create();
  </code></pre>
  
  <p>I have tried 4 different methods to do a receive/read.</p>
  
  <p><strong>ReceiveMessage.java</strong></p>
  
  <pre><code>MessageFetcher mf = new MessageFetcher("SM2ccd0dc43cea07bcc3f522b3e571eb79");
      System.out.println("message is " + mf.fetch().getBody());   &lt;-- Method 1
  
      Body body = new Body("Something here");                     &lt;-- Method 2
      Message message = new Message.Builder().action("/receive-sms")
              .method(Method.POST).body(body).build();
      MessagingResponse response = new MessagingResponse.Builder().message(message).build();
  
      ResourceSet&lt;Message&gt; messages = Message.reader().read();    &lt;-- Method 3
  
      for(Message message : messages){
          System.out.println(message);
      }
  
      try {
          System.out.println(response.toXml());
      } catch (TwiMLException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  
      post("/receive-sms", (req, res)-&gt; {                         &lt;-- Method 4
          // This gets the message content
          System.out.println(req.queryParams("Body"));            
          // GOT CONTENT
          // Must parse the format and get the content value
          // Must be able to get the latest message
  
          Message sms = new Message.Builder()
                  .body(new Body(""))
                  .build();
  
          MessagingResponse twiml = new MessagingResponse.Builder()
                  .message(sms)
                  .build();
  
          return twiml.toXml();
      });
  </code></pre>
  
  <p>I am currently using method 4. While it works, I am forced to send a message back since it is a post [This is using the sparkjava library]. I emailed back and forth with Twilio's technical help, and they kept recommending it to me to use the callback function in Twilio's REST api. I believe that the post method I have used is a callback function.</p>
  
  <p>Is there any way for me to read in the user's latest message without sending a response? If so, could you please explain a little in code how to do so? I am having difficulty in understanding how to translate it to Java since most of the code on their website appears to be in HTML.</p>
  
  <p>Appreciate any help.</p>