Skip to main content

Inbound SMS

Rent a dedicated phone number and receive all incoming SMS in real-time. Agile Telecom hosts the SIM and forwards messages to you via email or webhook—perfect for customer support lines, appointment reminders, or automated responses.

Delivery Methods​

Choose how you want to receive messages:

Email Delivery​

Messages arrive in your inbox automatically from smsin@agiletelecom.com with the subject "Agile Telecom -- SMS received".

FieldFormatExample
FromSender's phone number+393301234567
ToYour rented SIM number+393331234333
Date/TimeYYYYMMDDHHMMSS20260408143052
BodySMS textNews ON

Email is ideal for low-volume messages or integration with email-based systems.

HTTP POST Webhook​

Messages post to your webhook URL in real-time. Choose this for automation, databases, and immediate processing.

POST Request Format

Your webhook receives a POST with these form parameters:

ParameterDescriptionExample
originatorSender's phone number+393301234567
destinationYour SIM number+393331234333
date_timeReception timestamp (YYYYMMDDHHMMSS)20260408143052
textSMS message bodyNews ON

Required Response

Your server MUST respond with exactly:

+OK

If you don't respond with +OK within 30 seconds, Agile Telecom treats the delivery as failed and retries after 15 minutes. After 3 failed attempts, the message is discarded. Keep your webhook fast—offload heavy processing to background jobs.

Webhook Implementation Examples​

from flask import Flask, request

app = Flask(__name__)

@app.route('/webhook/sms', methods=['POST'])
def receive_sms():
# Extract parameters
originator = request.form.get('originator')
destination = request.form.get('destination')
date_time = request.form.get('date_time')
text = request.form.get('text')

# Process the message (async in background)
print(f"SMS from {originator}: {text}")

# Save to database
save_to_database(originator, destination, date_time, text)

# CRITICAL: respond with +OK immediately
return '+OK'

def save_to_database(originator, destination, date_time, text):
# Your database logic here
pass

if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)

**Deploy with Gunicorn (production):**

```bash
pip install flask gunicorn
gunicorn -w 4 -b 0.0.0.0:5000 app:app

## Best Practices

**Respond Fast**
Return `+OK` within 1 second. Process the message in a background queue, not in the webhook handler.

**Handle Duplicates**
Agile Telecom may retry failed deliveries. Store a hash of the originator + timestamp to detect duplicates and avoid processing the same message twice.

**Log Everything**
Keep a log of all received messages for debugging and compliance. Include the timestamp, originator, and response time.

**Monitor Failures**
If delivery fails 3 times, the message is discarded. Monitor your webhook uptime and alert on consecutive failures.

**Example: Duplicate Detection (Python)**

```python
import hashlib
from datetime import datetime, timedelta

processed_messages = {} # In production, use Redis or a database

@app.route('/webhook/sms', methods=['POST'])
def receive_sms():
originator = request.form.get('originator')
date_time = request.form.get('date_time')
text = request.form.get('text')

# Create unique key
message_hash = hashlib.md5(f"{originator}{date_time}".encode()).hexdigest()

# Check for duplicate (same sender in last 5 minutes)
if message_hash in processed_messages:
return '+OK' # Already processed

# Mark as processed
processed_messages[message_hash] = datetime.now()

# Cleanup old entries
cutoff = datetime.now() - timedelta(minutes=5)
processed_messages = {k: v for k, v in processed_messages.items() if v > cutoff}

# Process new message
save_to_database(originator, request.form.get('destination'), date_time, text)

return '+OK'

What's next?​