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 a an HTTP request to another server or execute 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.
...
Sl.No | Field Name | Drop-Down Parameters | Description |
---|---|---|---|
1 | Hook template |
| Select the 'Web' hook in this case. |
2 | Display Name | None | The name of the template that is being called. |
3 | Active | None | Please Check it to trigger the hook. |
4 | Content Type | None | The format in which the external application is expecting the notifications to come in. JSON (application/json) or FORM (application/x-www-form-urlencoded). |
5 | PayLoad URL | None | The web address at which the external application is expecting notifications to come in from Mifos X. |
6 | Events |
| You can select any one of the event for which the hook is triggered for. |
7 | Select Entity | For each selected event (ExExample: Portfolio), you have to select the entity from drop-down list like, Loan, Center, Client etc (for Portfolio event) | |
8 | Select Action | For each selected Event and Entity, you have to select the specific action by 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 )
- Go to Admin >> System >> Manage Hooks.
- 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)
'Create SMS Bridge Hook' Fields:
Sl.No Field Name Drop-Down Parameters Description 1 Hook template - Web
- SMS Bridge
Select the 'SMS Bridge' hook in this case. 2 Display Name None The name of the template that is being called. 3 Active None Please Check it to trigger the hook. 4 Payload URL None http://localhost:9191/modules/sms, Provide this as Payload URL only for "SMS Bridge", not for "Web" hook template. 5 Phone Number None This field has to be the phone number with which the person registered for the SMS service provider (ExExample: Twilio) and not some random number. 6 SMS Provider None The only value this field supports right now is Twilio. (In the future, it can be other providers as well). 7 SMS Provider Account Id None It is obtained from the SMS Provider website when you register there. Example:- When you pay and register for an account in Twilio. 8 SMS Provider Token None SMS Provider Token is the token generated by the bridge (required to communicate with the SMS provider) on starting the application. 9 Events - 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.) 7 Select Entity For each selected event, (ExExample: Portfolio), you have to select the entity from drop-down list like, Loan, Center, Client, etc ( for Portfolio event) 8 Select 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 a 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.
...