This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • Short Messaging Service (SMS) Gateway Integration [In Progress]

Access to add and change pages is restricted. See: https://cwiki.apache.org/confluence/display/OFBIZ/Wiki+access

Skip to end of metadata
Go to start of metadata

Many eCommerce websites, especially in Asian countries, nowadays use short messaging service (SMS) to notify customers with their order detail, shipment tracking, one time passwords etc. So we thought of contributing generic code and one sample implementation of SMS gateway integration to the OFBiz.

User Stories:

  • As a user/developer, I should be able to configure multiple SMS gateway vendors into the system so that there will not be any dependency on single SMS gateway vendors.
  • As a developer, the implementation process for multiple SMS gateway vendors should be simple and generic.
  • As a user, I should be able to send different types of SMS like order confirmation, new user registrations etc using any of the SMS gateway setup in the system.
  • As a user, I should be able to setup the static/dynamic contents for the SMS to be sent.
  • As a user, I should be able to configure different SMS gateways for different stores.

Taking the reference of already implemented email, shipment and payment gateway integration in OFBiz, the database schematic for SMS gateway integration can be designed as follows:


Brief about the data model:

  1. ProductStoreTelecomSetting:
    This entity will be used for associating all gateway related setting with the product store. The details of each field in the entity are as below:
    -- productStoreId: will hold the value of the Product Store to which gateway settings need to be applied.
    -- telecomMethodTypeId: will hold the value of the type of telecom method user wants to use. for ex. SMS, MMS, WhatsApp etc. This entity will have relatioship with TelecomMethodType entity.
    -- telecomMsgTypeEnumId:  will hold the value of type of telecom message user wants to send. for ex. ORDER_SMS, INVOICE_SMS, USER_REGISTRATION_SMS, OTP etc. This entity will have relatioship with Enumeration entity.
    -- telecomCustomMethodId: will hold the value of custom method which needs to be called to send the telecom message. This entity will have relatioship with CustomMethod.
    -- telecomGatewayConfigId: will hold the value of which gateway configurations need to be used.
  2. TelecomGatewayConfig:
    This entity will hold the value of telecomGatewayConfigId and bridging the ProductStoreTelecomSetting with the custom entity specific to the telecom gateway. i.e. here it is Msg91GatewayConfig.
  3. TelecomMethodType:
    This type entity will hold the values of the type of message user wants to send. for ex. ORDER_SMS, INVOICE_SMS etc.
  4. Msg91GatewayConfig:
    This will be the custom entity specific to the telecom gateway which will hold all configuration related values of the gateway.

At service level, we will be writing one common generic service to send SMS as like sendEmail in OFBiz. The user/developer will need to write the custom service, specific to the API provider/vendor to prepare vendor specific parameters or data which will be needed for calling SMS APIs.


Steps to test the initial pass of the SMS gateway integration:

  1. Download the patch file (OFBIZ-10457) and plugin zip file (msg91.zip) attached to the ticket.
  2. Apply the patch to the latest trunk codebase.
  3. Unzip the msg91.zip file and put the folder into the plugin folder of your truck codebase.
  4. Build and restart the server.
  5. Reload the fresh data or you can load the data following data from XML data import tool.

    <SystemProperty systemResourceId="general" systemPropertyId="telecom.notifications.enabled" systemPropertyValue="N" description="Telecom notifications enabled (Y|N)"/>
    <!-- Telecom Services Seed Data -->
    <EnumerationType enumTypeId="TELECOM_MSG" description="Telcom Message Type Enum" hasTable="N"/>
    <TelecomMethodType telecomMethodTypeId="SMS" description="Short Messaging Service Method"/>
    <TelecomMethodType telecomMethodTypeId="WHATSAPP" description="WhatsApp Messaging Service Method"/>
    <CustomMethodType customMethodTypeId="TELECOM_GATEWAY" description="Telecom Gateway Custom Method"/>

    <!-- Custom Demo Data -->
    <Enumeration enumId="ORDER_SMS" description="Order Placed SMS" enumTypeId="TELECOM_MSG" sequenceId="01"/>
    <Enumeration enumId="INVOICE_SMS" description="Invoice Generated SMS" enumTypeId="TELECOM_MSG" sequenceId="02"/>
    <Enumeration enumId="SHIPMENT_SMS" description="Shipment Initiated SMS" enumTypeId="TELECOM_MSG" sequenceId="03"/>
    <TelecomGatewayConfig telecomGatewayConfigId="MSG91" description="MSG91 SMS Gateway Configuration"/>
    <CustomMethod customMethodId="TG_MSG91" customMethodName="sendMsg91Sms" customMethodTypeId="TELECOM_GATEWAY" description="Service to send SMS using MSG91 Gateway"/>
    <ProductStoreTelecomSetting productStoreId="9000" telecomMethodTypeId="SMS" telecomMsgTypeEnumId="ORDER_SMS" telecomCustomMethodId="TG_MSG91" telecomGatewayConfigId="MSG91" />
    <Msg91GatewayConfig telecomGatewayConfigId="MSG91" apiUrl="http://api.msg91.com/api/sendhttp.php" country="" route="4" authkey="" sender="IOFBIZ"/>

  6. Sign up to the msg91 services to get the authkey and free SMS quota.

  7. Find your authkey after completing the sign up process.
  8. Alter the system property data to change "telecom.notifications.enabled" flag to "Y".
  9. Go to "Msg91GatewayConfig" entity. Here you need to set following fields.
    -- country: Set it to 91 if you want to send SMS in India, set it to 1 if you want to send SMS to USA, for rest of countries, it should be set to 0.
    -- authkey: The authkey you got on your API dashboard once you complete registration process.
  10. After doing all the above mentioned steps, go to webtools and click on run service menu.
  11. Enter service name as "sendTelecomMessage".
  12. Put following parameters:
    -- productStoreId: 9000
    -- telecomMsgTypeEnumId: ORDER_SMS
    -- telecomMethodTypeId: Its optional so can be left blank.
    -- numbers: comma seperated numbers. If you are sending SMS in India or USA, then the numbers should be excluding country code. Otherwise numbers should include country code too.
    -- message: message you want to send to.
  13. After entering the required parameters, run the service.
  14. Wait for some time to receive message on your phone. If it is taking too much time, go to the delivery section of the msg91 console to see if message is submitted to the API provider or not.


  • No labels