Telstra_Messaging
Telstra_Messaging - the Ruby gem for the Telstra Messaging API
Introduction
Features
The Telstra Messaging API provides the features below.
Feature | Description |
---|---|
Dedicated Number |
Provision a mobile number for your account to be used as from address in the API |
Send Messages |
Sending SMS or MMS messages |
Receive Messages |
Telstra will deliver messages sent to a dedicated number or to the notifyURL defined by you |
Broadcast Messages |
Invoke a single API call to send a message to a list of numbers provided in to
|
Delivery Status |
Query the delivery status of your messages |
Callbacks |
Provide a notification URL and Telstra will notify your app when a message status changes |
Alphanumeric Identifier |
Differentiate yourself by providing an alphanumeric string in from . This feature is only available on paid plans |
Concatenation |
Send messages up to 1900 characters long and Telstra will automaticaly segment and reassemble them |
Reply Request |
Create a chat session by associating messageId and to number to track responses received from a mobile number. We will store this association for 8 days |
Character set |
Accepts all Unicode characters as part of UTF-8 |
Bounce-back response |
See if your SMS hits an unreachable or unallocated number (Australia Only) |
Queuing |
Messaging API will automatically queue and deliver each message at a compliant rate. |
Emoji Encoding |
The API supports the encoding of the full range of emojis. Emojis in the reply messages will be in their UTF-8 format. |
Delivery Notification or Callbacks
The API provides several methods for notifying when a message has been delivered to the destination.
- When you send a message there is an opportunity to specify a
notifyURL
. Once the message has been delivered the API will make a call to this URL to advise of the message status. - If you do not specify a URL you can always call the
GET /status
API to get the status of the message.
Getting Access to the API
- Register at https://dev.telstra.com.
- After registration, login to https://dev.telstra.com and navigate to the My apps page.
- Create your application by clicking the Add new app button
- Select API Free Trial Product when configuring your application. This Product includes the Telstra Messaging API as well as other free trial APIs. Your application will be approved automatically.
- There is a maximum of 1000 free messages per developer. Additional messages and features can be purchased from https://dev.telstra.com.
- Note your
Client key
andClient secret
as these will be needed to provision a number for your application and for authentication.
Now head over to Getting Started where you can find a postman collection as well as some links to sample apps and SDKs to get you started.
Happy Messaging!
Frequently Asked Questions
Q: Is creating a subscription via the Provisioning call a required step?
A. Yes. You will only be able to start sending messages if you have a provisioned dedicated number. Use Provisioning to create a dedicated number subscription, or renew your dedicated number if it has expired.
Q: When trying to send an SMS I receive a 400 Bad Request
response. How can I fix this?
A. You need to make sure you have a provisioned dedicated number before you can send an SMS. If you do not have a provisioned dedicated number and you try to send a message via the API, you will get the error below in the response:
{
\"status\":\"400\",
\"code\":\"DELIVERY-IMPOSSIBLE\",
\"message\":\"Invalid \\'from\\' address specified\"
}
Use Provisioning to create a dedicated number subscription, or renew your dedicated number if it has expired.
Q: How long does my dedicated number stay active for?
A. When you provision a dedicated number, by default it will be active for 30 days.
You can use the activeDays
parameter during the provisioning call to increment or decrement the number of days your dedicated number will remain active.
Note that Free Trial apps will have 30 days as the maximum activeDays
they can add to their provisioned number. If the Provisioning call is made several times within that 30-Day period, it will return the expiryDate
in the Unix format and will not add any activeDays until after that expiryDate
.
Q: Can I send a broadcast message using the Telstra Messaging API?
A. Yes. Recipient numbers can be in the form of an array of strings if a broadcast message needs to be sent, allowing you to send to multiple mobile numbers in one API call.
A sample request body for this will be: {\"to\":[\"+61412345678\",\"+61487654321\"],\"body\":\"Test Message\"}
Q: Can I send SMS and MMS to all countries?
A. You can send SMS and MMS to all countries EXCEPT to countries which are subject to global sanctions namely: Burma, Côte d'Ivoire, Cuba, Iran, North Korea, Syria.
Q: Can I use Alphanumeric Identifier
from my paid plan via credit card?
A. Alphanumeric Identifier
is only available on Telstra Account paid plans, not through credit card paid plans.
Q: What is the maximum sized MMS that I can send?
A. This will depend on the carrier that will receive the MMS. For Telstra it's up to 2MB, Optus up to 1.5MB and Vodafone only allows up to 500kB. You will need to check with international carriers for thier MMS size limits.
Q: How is the size of an MMS calculated?
A. Images are scaled up to approximately 4/3 when base64 encoded. Additionally, there is approximately 200 bytes of overhead on each MMS. Assuming the maximum MMS that can be sent on Telstra’s network is 2MB, then the maximum image size that can be sent will be approximately 1.378MB (1.378 x 1.34 + 200, without SOAP encapsulation).
Q: How is an MMS classified as Small or Large?
A. MMSes with size below 600kB are classed as Small whereas those that are bigger than 600kB are classed as Large. They will be charged accordingly.
Q: Are SMILs supported by the Messaging API?
A. While there will be no error if you send an MMS with a SMIL presentation, the actual layout or sequence defined in the SMIL may not display as expected because most of the new smartphone devices ignore the SMIL presentation layer. SMIL was used in feature phones which had limited capability and SMIL allowed a powerpoint type presentation to be provided. Smartphones now have the capability to display video which is the better option for presentations. It is recommended that MMS messages should just drop the SMIL.
Q: How do I assign a delivery notification or callback URL?
A. You can assign a delivery notification or callback URL by adding the notifyURL
parameter in the body of the request when you send a message. Once the message has been delivered, a notification will then be posted to this callback URL.
Q: What is the difference between the notifyURL
parameter in the Provisoning call versus the notifyURL
parameter in the Send Message call?
A. The notifyURL
in the Provisoning call will be the URL where replies to the provisioned number will be posted.
On the other hand, the notifyURL
in the Send Message call will be the URL where the delivery notification will be posted, e.g. when an SMS has already been delivered to the recipient.
Getting Started
Below are the steps to get started with the Telstra Messaging API.
- Generate an OAuth2 token using your
Client key
andClient secret
. - Use the Provisioning call to create a subscription and receive a dedicated number.
- Send a message to a specific mobile number.
Run in Postman
<a href="https://app.getpostman.com/run-collection/ded00578f69a9deba256#?env%5BMessaging%20API%20Environments%5D=W3siZW5hYmxlZCI6dHJ1ZSwia2V5IjoiY2xpZW50X2lkIiwidmFsdWUiOiIiLCJ0eXBlIjoidGV4dCJ9LHsiZW5hYmxlZCI6dHJ1ZSwia2V5IjoiY2xpZW50X3NlY3JldCIsInZhbHVlIjoiIiwidHlwZSI6InRleHQifSx7ImVuYWJsZWQiOnRydWUsImtleSI6ImFjY2Vzc190b2tlbiIsInZhbHVlIjoiIiwidHlwZSI6InRleHQifSx7ImVuYWJsZWQiOnRydWUsImtleSI6Imhvc3QiLCJ2YWx1ZSI6InRhcGkudGVsc3RyYS5jb20iLCJ0eXBlIjoidGV4dCJ9LHsiZW5hYmxlZCI6dHJ1ZSwia2V5IjoiQXV0aG9yaXphdGlvbiIsInZhbHVlIjoiIiwidHlwZSI6InRleHQifSx7ImVuYWJsZWQiOnRydWUsImtleSI6Im9hdXRoX2hvc3QiLCJ2YWx1ZSI6InNhcGkudGVsc3RyYS5jb20iLCJ0eXBlIjoidGV4dCJ9LHsiZW5hYmxlZCI6dHJ1ZSwia2V5IjoibWVzc2FnZV9pZCIsInZhbHVlIjoiIiwidHlwZSI6InRleHQifV0=\"><img src="https://run.pstmn.io/button.svg\" alt="Run in Postman"/>
Sample Apps
SDK Repos
- Messaging API - PHP SDK
- Messaging API - Python SDK
- Messaging API - Ruby SDK
- Messaging API - NodeJS SDK
- Messaging API - .Net2 SDK
- Messaging API - Java SDK
Blog Posts
For more information on the Messaging API, you can read these blog posts:
-
API version: 2.2.9
-
Package version: 1.0.6
Installation
Build a gem
To build the Ruby code into a gem:
gem build Telstra_Messaging.gemspec
Then either install the gem locally:
gem install ./Telstra_Messaging-1.0.6.gem
(for development, run gem install --dev ./Telstra_Messaging-1.0.6.gem
to install the development dependencies)
or publish the gem to a gem hosting service, e.g. RubyGems.
Finally add this to the Gemfile:
gem 'Telstra_Messaging', '~> 1.0.6'
Install from Git
If the Ruby gem is hosted at a git repository: https://github.com/Telstra/MessagingAPI-SDK-Ruby, then add the following in the Gemfile:
gem 'Telstra_Messaging', :git => 'https://github.com/Telstra/MessagingAPI-SDK-Ruby.git'
Include the Ruby code directly
Include the Ruby code directly using -I
as follows:
ruby -Ilib script.rb
Getting Started
Please follow the installation procedure and then run the following code:
# Load the gem
require 'Telstra_Messaging'
api_instance = Telstra_Messaging::AuthenticationApi.new
client_id = 'client_id_example' # String |
client_secret = 'client_secret_example' # String |
grant_type = 'client_credentials' # String |
begin
#Generate OAuth2 token
result = api_instance.auth_token(client_id, client_secret, grant_type)
p result
rescue Telstra_Messaging::ApiError => e
puts "Exception when calling AuthenticationApi->auth_token: #{e}"
end
Documentation for API Endpoints
All URIs are relative to https://tapi.telstra.com/v2
Class | Method | HTTP request | Description |
---|---|---|---|
Telstra_Messaging::AuthenticationApi | auth_token | POST /oauth/token | Generate OAuth2 token |
Telstra_Messaging::MessagingApi | get_mms_status | GET /messages/mms/{messageid}/status | Get MMS Status |
Telstra_Messaging::MessagingApi | get_sms_status | GET /messages/sms/{messageId}/status | Get SMS Status |
Telstra_Messaging::MessagingApi | retrieve_mms_responses | GET /messages/mms | Retrieve MMS Responses |
Telstra_Messaging::MessagingApi | retrieve_sms_responses | GET /messages/sms | Retrieve SMS Responses |
Telstra_Messaging::MessagingApi | send_mms | POST /messages/mms | Send MMS |
Telstra_Messaging::MessagingApi | send_sms | POST /messages/sms | Send SMS |
Telstra_Messaging::ProvisioningApi | create_subscription | POST /messages/provisioning/subscriptions | Create Subscription |
Telstra_Messaging::ProvisioningApi | delete_subscription | DELETE /messages/provisioning/subscriptions | Delete Subscription |
Telstra_Messaging::ProvisioningApi | get_subscription | GET /messages/provisioning/subscriptions | Get Subscription |
Documentation for Models
- Telstra_Messaging::DeleteNumberRequest
- Telstra_Messaging::GetSubscriptionResponse
- Telstra_Messaging::InboundPollResponse
- Telstra_Messaging::MMSContent
- Telstra_Messaging::Message
- Telstra_Messaging::MessageSentResponse
- Telstra_Messaging::OAuthResponse
- Telstra_Messaging::OutboundPollResponse
- Telstra_Messaging::ProvisionNumberRequest
- Telstra_Messaging::ProvisionNumberResponse
- Telstra_Messaging::SendMmsRequest
- Telstra_Messaging::SendSMSRequest
- Telstra_Messaging::Status
Documentation for Authorisation
auth
- Type: OAuth
- Flow: application
- Authorisation URL:
-
Scopes:
- NSMS: NSMS