Receive an SMS message using Infobip API
In this tutorial, you will learn how to send an SMS message from your handset to a webhook that you have configured. This will simulate a scenario in which an end user can reply to an SMS and their message gets stored in a third-party application that you manage.
The tutorial assumes basic familiarity with APIs. It is important however that you are faimiliar with the webhook technology and how to utilize it for this project. For the ease of replicating the scenario, we have used a free online webhook tool, HookRelay (opens in a new tab).
Prerequisites
- Infobip account (opens in a new tab). If you do not have one create a free trial account (opens in a new tab).
- The SMS Sender (opens in a new tab). If you are in the free trial period, you can use Infobip's test sender,
ServiceSMS
. If you want to configure your custom sender, request a new number or an alphanumeric sender through the Infobip account (opens in a new tab) or using Infobip Numbers API (opens in a new tab). - Ability to send an SMS (opens in a new tab).
- A webhook that will listen to incoming events.
Implementation
- Buy a number capable of receiving incoming SMS traffic.
- Set up a webhook.
- Add webhook details to the number you've purchased.
- Receive an SMS on your webhook.
Buy a number
To buy a number, you'll need to log into your Infobip account (opens in a new tab). If using the Infobip test sender, skip this section.
- Expand the Channels and Numbers icon on the left-hand side menu, and select Numbers.
- On the Numbers screen, click Buy Number.
- Set up your number preferences, like a country, number type, etc.
- Once you chose all details, click Buy to finalize the purchase.
Set up a webhook
For the purpose of this guide, we will use a simple online webhook tool, HookRelay (opens in a new tab). This section will show you how to create and account and configure the webhook with HookRelay.
Step 1. Sign in with git credentials
Sign in to HookRelay (opens in a new tab) with your GitHub or GitLab credentials. Once logged in, you'll access a dashboard where you can start creating webhooks.
Step 2. Create a webook
To create an inbound webhook, from your dashboard, click the New Hook button on the top right. That will take you to the configuration screen where all you need providing is a descriptive name for your webhook, e.g. Infobip Receive SMS and to make sure it's able to receive incoming traffic.
Once you click the Create hook button, you'll be able to view and copy its URL that you will need to add to your number configuration in your Infobip account.
Configure your number with webhook details
Head back to your Infobip account (opens in a new tab) and access your number configuration page (Channels and Numbers > Numbers). If using the Infobip test sender, configure that number.
- Select the number and click the SMS tab.
- Under Keywords, click the plus icon to add a keyword.
- Use the Forwarding action dropdown to select the Forward to HTTP option.
- Under URL provide the URL of the webhook that you have created.
- Select MO_JSON_2 as a Renderer Type.
- Click CONFIGURE to save configuration.
Receive an SMS on your webhook
Now that we have everything configured, to test that all works as expected, send an SMS (opens in a new tab) from your handset to the number you have purchased. This should trigger an event, and you should see your message in JSON format arriving at your webhook.
{
"results": [
{
"from": "447415774432",
"to": "447491163443",
"text": "SEND10",
"cleanText": "",
"keyword": "SEND10",
"receivedAt": "2025-03-13T11:43:00.603+0000",
"smsCount": 1,
"messageId": "2491729790183409612",
"pairedMessageId": null,
"price": {
"pricePerMessage": 0,
"currency": "EUR"
},
"callbackData": null
}
],
"messageCount": 1,
"pendingMessageCount": 0
}