Manage Hooks

Hooks are a mechanism to trigger custom code on the occurrence of events. In other words, Hooks are notifications sent to any external application (which can be accessed through a web address) from Mifos X in the format the external application wants.  Each template during hook creation represents custom behavior on what actions should be taken on the triggering of a registered event for a hook. The action taken might be firing an HTTP request to another server or executing an internal code.

 In order for Mifos X to send webhook payloads, your server needs to be accessible from the Internet. Mifos X will send along a few HTTP headers to differentiate between event types.

X-Mifos-Entity - The entity type that was triggered. 
X-Mifos-Action - The action triggered on the entity type. 
X-Mifos-Platform-TenantId - The tenant which experienced the event.

You can create two types of Hooks using Hook Templates.

  •  Web
  •  SMS Bridge

Create a Web Hook

  1. Go to Admin >> System and click on Manage Hooks.

     2. Click on 'Manage Hooks' and then click on '+Create a Hook' to see  the following window. (Here, select Hook Template as "Web" from drop-down menu)

      

     3. "Create a Web Hook" Fields:



Sl.NoField NameDrop-Down Parameters Description
1Hook template
  • Web
  • SMS Bridge
Select the 'Web' hook in this case.
2Display NameNoneThe name of the template that is being called.
3ActiveNonePlease Check it to trigger the hook.
4Content TypeNoneThe format in which the external application is expecting the notifications to come in. JSON (application/json) or FORM (application/x-www-form-urlencoded).
5PayLoad URLNoneThe web address at which the external application is expecting notifications to come in from Mifos X.
6Events
  • Account Transfer
  • Accounting
  • Authorization
  • Configuration
  • Data table
  • Jobs
  • Organization
  • Portfolio
  • Portfolio_Center
  • Portfolio_Group
  • Survey
  • Transaction Loan
  • Transaction Savings
  • XBRL Mapping.
You can select any one of the event for which the hook is triggered for.
7Select Entity
For each selected event (Example: Portfolio), you have to select the entity from drop-down list like, Loan, Center, Client etc (for Portfolio event)
8Select Action
For each selected Event and Entity, you have to select the specific action from the drop-down list.

      4. Click on "Submit" button to create a 'Web' Hook. 

Create an SMS Bridge Hook

Note :i)  You need to clone https://github.com/mgeiss/mifos-twilio-bridge and do a gradlew bootRun to start the application which will act as a bridge between Mifos X and Twilio.

         ii) Your mobile number should be registered to twilio. (See the link for more information: http://www.twilio.com/help/faq/phone-numbers )

  1. Go to Admin >> System >> Manage Hooks.
  2.  Click on 'Manage Hooks' and then click on '+Create a Hook' to see  the following window. (Here, select Hook Template as "SMS Bridge" from drop-down menu)



  3. 'Create SMS Bridge Hook' Fields:

    Sl.NoField NameDrop-Down Parameters Description
    1Hook template
    • Web
    • SMS Bridge
    Select the 'SMS Bridge' hook in this case.
    2Display NameNoneThe name of the template that is being called.
    3ActiveNonePlease Check it to trigger the hook.
    4Payload URLNone http://localhost:9191/modules/sms, Provide this as Payload URL only for "SMS Bridge", not for "Web" hook template.
    5Phone NumberNoneThis field has to be the phone number with which the person registered for the SMS service provider (Example: Twilio) and not some random number.
    6SMS ProviderNoneThe only value this field supports right now is Twilio. (In the future, it can be other providers as well).
    7SMS Provider Account IdNoneIt is obtained from the SMS Provider website when you register there. Example:- When you pay and register for an account in Twilio.
    8SMS Provider TokenNoneSMS Provider Token is the token generated by the bridge (required to communicate with the SMS provider) on starting the application.
    9Events
    • Account Transfer
    • Accounting
    • Authorization
    • Configuration
    • Datatable
    • Jobs
    • Organization
    • Portfolio
    • Portfolio_Center
    • Portfolio_Group
    • Survey
    • Transaction Loan
    • Transaction Savings
    • XBRL Mapping.
    You can select any one of the event for which the hook is triggered for. (Note: The only 2 events in Mifos X currently supported by the bridge application are CREATE CLIENT and REPAYMENT LOAN. The bridge application won't react to other events registered for the SMS Bridge Hook.)
    7Select Entity
    For each selected event, (Example: Portfolio), you have to select the entity from drop-down list like, Loan, Center, Client, etc ( for Portfolio event)
    8Select Action
    For each selected Event and Entity, you have to select the specific action from the drop-down list.

   4. Click on 'Submit' button to create a "SMS Bridge" hook.

Associate a UGD template with an SMS Bridge Hook: Click Here to watch the tutorial video.

Note: i. Do not create an SMS Bridge hook with your own mobile number if you have not registered for Twilio. 

          ii. If you create multiple clients in Mifos X with the same mobile number for testing (by deleting the client and creating a new one), that might not be supported by the bridge application because of unique mobile number constraints.

          iii. If you somehow lose/clear the database contents for bridge application, it is better to delete the hook in Mifos X and create a new one.