Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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 shipment payment gateway integration in OFBiz, the database schematic for SMS gateway integration can be designed as follows:

Image RemovedImage Added

Brief about the data model:

  1. SmsConfigTypeProductStoreTelecomSetting:
    It will store the name of the custom entity which contains the configuration data for connecting and sending SMS. For example, in above data model, we have custom vendor specific entities like SmsConfigMsg91 and SmsConfigTextLocal.
  2. SmsConfig:
    Config entity saving the association of an custom SMS configuration entity with configuration type.
  3. SmsTemplateSetting:
    It will contain the information for the template/content of the SMS and type of the SMS like order confirmation SMS, New user registration SMS etc.
  4. ProductStoreSmsSetting:
    It will contain the association of product store with the SMS template setting.
  5. 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.
  6. 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.
  7. TelecomMethodType:
    This type entity will hold the values of the type of message user wants to send. for ex. ORDER_SMS, INVOICE_SMS etc.
  8. Msg91GatewayConfig:
    This will be the custom entity specific to the telecom gateway which will hold all configuration related values of the gatewaySmsConfigMsg91/SmsConfigTextLocal:
    The custom configuration entity which will save the basic and required fields and information for using the SMS Gateway API services for different vendors.

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.