β οΈ Example Project Notice
Not intended for production use without proper security review and modifications.
- π± Example n8n Integration
n8n is a powerful workflow automation tool that allows you to integrate the SMSGate with AI services to create intelligent SMS-based applications. This example demonstrates how to build an AI-powered joke agent that responds to SMS messages with automated jokes.
Example Project Features:
- Receives SMS messages via webhook
- Uses AI (OpenRouter/Grok-4) to understand user requests
- Fetches jokes from the Joke API
- Sends joke responses back to the user via SMSGate API
This example intentionally omits:
- Production-grade error handling
- Rate limiting
- Advanced security features
- Webhook authentication/verification
Recommended for:
- π§ͺ Testing SMSGate integration
- π Learning n8n and AI integration
- n8n account or self-hosted instance
- SMSGate API credentials
- OpenRouter API credentials
- Open your n8n instance
- Create a new workflow
- Select "Import from URL" option in the workflow editor
- Enter the following URL: https://raw.githubusercontent.com/android-sms-gateway/example-webhooks-n8n/master/workflow.json
- Click "Import"
- In n8n, go to Credentials β Add credential
- Select HTTP Basic Auth type
- Name it "SMSGate Dev"
- Enter your SMSGate API credentials:
- Username: Your API username
- Password: Your API password
- In n8n, go to Credentials β Add credential
- Select OpenRouter API type
- Name it "OpenRouter account"
- Enter your OpenRouter API key
- Note the webhook URL from the Webhook node
- Configure your SMSGate to send messages to this webhook URL
Replace
curl -X POST -u <username>:<password> \ -H "Content-Type: application/json" \ -d '{ "url": "<your-n8n-webhook-url>", "event": "sms:received" }' \ https://api.sms-gate.app/3rdparty/v1/webhooks
<your-n8n-webhook-url>
with the actual URL of your n8n webhook node.
- Send an SMS message to the device with SMSGate app
- The webhook node will receive the message and pass it to the AI agent
- The AI agent will process the message and generate a response
- The response will be sent back to the user
The workflow consists of the following key nodes:
- Purpose: Receives SMS messages from the SMS Gateway
- Input: SMS payload with
phoneNumber
andmessage
- Output: Passes message content to the AI agent
- Purpose: Maintains conversation context per phone number
- Session Key: Uses phone number for unique sessions
- Benefit: Remembers previous interactions with the same user
- Purpose: Processes user requests and generates responses
- System Prompt: Optimized for SMS communication
- Capabilities: Understands natural language and uses available tools
- Purpose: Provides AI language processing
- Model: Grok 4 Fast
- Integration: Connected to the AI agent for intelligent responses
- Purpose: Fetch jokes and API documentation
- Integration: Available as tools for the AI agent
- Flexibility: AI can query specific joke types based on user preferences
- Purpose: Sends responses back via SMSGate API
- Endpoint:
https://api.sms-gate.app/3rdparty/v1/messages
- Authentication: Uses configured credentials
- Payload: Includes response text and recipient phone number
This example code is released under Apache License 2.0.