Showing posts with label Automated Bulk SMS. Show all posts
Showing posts with label Automated Bulk SMS. Show all posts

Tuesday, March 10, 2015

Mifos X Messenger Installation

Mifos X Messenger, the SMS Messaging System which sends SMS messages at different points in the Mifos X workflow can be installed by following these steps. I've tested out these steps for Debian / Ubuntu and it should be similar for Mac OSX, plus we've also been able to install on Windows, where step 1 is not applicable, but other steps are similar:

1. Install ruby version manager rvm see https://rvm.io/rvm/install:

    \curl -sSL https://get.rvm.io | bash -s stable --rails

2. Download messenger source code:

      git clone https://github.com/SanjoseSolutions/mifosx-messenger.git

3. Install dependencies

   bundle install

4. Configure mifosx-messenger

   setup config.yml

5.  Run messenger

   ruby app.rb

6. Setup Mifos X Webhooks to connect with MifosX Messenger

  In Mifos X go to Admin > System > Manage Hooks
  Click "Create Hook"
  Hook Template: Web

  Active: checked
  Content Type: json
  Payload URL: http://localhost:3000
  Events: transactions_loan : LOAN : REPAYMENT
                transactions_savings: SAVINGSACCOUNT: WITHDRAWAL 
                transactions_savings: SAVINGSACCOUNT: DEPOSIT

More details, video coming soon

Wednesday, October 15, 2014

MifosX Messenger - automated SMS notification app

As mentioned in my previous blog post, the architecture of MifosX makes it play very nicely with heterogenous technologies using the REST API and Webhooks to communicate. To fulfill my client's requirement, I started working on a SMS sending application to notify group members about financial transactions like loan repayments, and deposits and withdrawals to savings accounts.
I used the Sinatra framework of the ruby programming language because of it's simplicity. Though not as famous as Rails, it's elder brother, Sinatra is perfect for quickly writing great applications without enforcing a directory structure on the programmer. A simple application in sinatra can be as few as 5 lines. Your hello world in sinatra would look like (you won't believe this):

require 'sinatra'

get '/hi' do
  "Hello World!"
end

Having several years experience developing Web Applications, I've used several kinds of frameworks for different tasks. MVC frameworks like perl-Catalyst, ruby-on-Rails and python-django are great for developing modular applications. However, as the above code snippet shows, it's possible to get cracking with a much leaner and meaner application with a intuitive block for each request path and request type. I had the joy of using another microframework like Sinatra before: perl's Dancer framework. Dancer proved great for implementing a webhook handler app. With the help of CPAN's great array of libraries and modules, I could quickly develop an application with a few lines of code.

Having emphasized the simplicity and speed of developing with microframeworks like Sinatra, it's flexibility with directory structure shouldn't deter those looking to write maintainable applications. Since ruby itself is object oriented and provides neat ways to organize a growing project, it's possible to write a perfectly modular and well organized and maintainable application with Sinatra. In fact, MifosX Messenger uses a handful of classes which specialize in the different functionalities required to get the app working. The workflow starts when a financial transaction is recorded in MifosX.



As the above sequence diagram shows (click for full size view), MifosX Messenger gets notified when any financial transaction it has subscribed to is performed. It parses the JSON in the POST request data received and uses the clientId, loanId and resourceId to fetch information from Mifos via the REST API. Once it has collected the necessary information, it uses a MessageTemplate class to construct the SMS and sends it to the mobile number of the client.