Double-check that Ngrok is still running on your localhost port. Now Twilio will be able to find your application – but first, we need to tell Twilio where to look.

Configure your webhook URL

For Twilio to know where to look, you need to configure your Twilio phone number to call your webhook URL whenever a new message comes in.

Log into Twilio.com and go to the Console’s Numbers page. Click on your SMS-enabled phone number. Find the Messaging section. The default “CONFIGURE WITH” is what you’ll need: “Webhooks/TwiML”. In the “A MESSAGE COMES IN” section, select “Webhook” and paste in your ngrok URL plus /sms.



Save your changes – you’re ready!

Test your application

As long as your localhost and the Ngrok servers are up and running, we’re ready for the fun part – testing our new Finatra application!

Send a text message from your mobile phone to your Twilio phone number. You should see an HTTP request in your Ngrok console. Your Finatra app will process the text message, and you’ll get your response back as an SMS.



Show me the money

When someone sends an SMS to your Twilio phone number, Twilio makes an HTTP request to your server asking for instructions on what to do next. Once you receive the request, you can tell Twilio to reply with an SMS, kick off a phone call, store details about the SMS in your database, or trigger something else entirely – it’s all up to you!

We can use the incoming message to filter our responses. In this case, we want to respond to a Balance if someone requests it. We’re formatting our Balance as USD, but check out this post for more information on formatting international currency in Scala. Since our application isn’t hooked up to a database, we’ll just use a random number instead. Update your HelloController class to have the following code: