> For the complete documentation index, see [llms.txt](https://docs.mifos.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mifos.org/mifosx/user-manual/for-administrators-mifos-x-platform/administration/system/manage-hooks.md).

# 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.

&#x20;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**.

* &#x20;Web
* &#x20;SMS Bridge

#### Create a Web Hook

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

&#x20;    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)

![](https://mifosforge.jira.com/wiki/download/thumbnails/82706605/w4.jpg?version=2\&modificationDate=1415605609268\&cacheVersion=1\&api=v2\&width=900)

&#x20;  3\. "Create a Web Hook" Fields:

| SI.No | Field Name    | Drop-Down Parameters                                                                                                                                                                                                                                                                                                         | Description                                                                                                                                                                                                                                                                                        |
| ----- | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 1     | Hook template | <p></p><ul><li>Web</li><li>SMS Bridge</li></ul>                                                                                                                                                                                                                                                                              | 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](http://en.wikipedia.org/wiki/JSON#Data_types.2C_syntax_and_example)) or FORM ([application/x-www-form-urlencoded](http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1)). |
| 5     | PayLoad URL   | None                                                                                                                                                                                                                                                                                                                         | The web address at which the external application is expecting notifications to come in from Mifos X.                                                                                                                                                                                              |
| 6     | Events        | <p></p><ul><li>Account Transfer</li><li>Accounting</li><li>Authorization</li><li>Configuration</li><li>Data table</li><li>Jobs</li><li>Organization</li><li>Portfolio</li><li>Portfolio\_Center</li><li>Portfolio\_Group</li><li>Survey</li><li>Transaction Loan</li><li>Transaction Savings</li><li>XBRL Mapping.</li></ul> | You can select any one of the event for which the hook is triggered for.                                                                                                                                                                                                                           |
| 7     | Select 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)                                                                                                                                               |
| 8     | Select Action |                                                                                                                                                                                                                                                                                                                              | For each selected Event and Entity, you have to select the specific action from the drop-down list.                                                                                                                                                                                                |

&#x20;   4\. Click on "Submit" button to create a 'Web' Hook.&#x20;

#### Create an SMS Bridge Hook

**Note :**&#x69;)  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.

&#x20;        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. &#x20;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).

![](https://mifosforge.jira.com/wiki/download/thumbnails/82706605/w3.jpg?version=1\&modificationDate=1415605431176\&cacheVersion=1\&api=v2\&width=900)

'   3. Create SMS Bridge Hook' Fields:

| SI.No | Field Name              | Drop-Down Parameters                                                                                                                                                                                                                                                                                                        | Description                                                                                                                                                                                                                                                                              |
| ----- | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 1     | Hook Template           | <p></p><ul><li>Web</li><li>SMS Bridge</li></ul>                                                                                                                                                                                                                                                                             | 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 (Example: 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 ](https://github.com/mgeiss/mifos-twilio-bridge)(required to communicate with the SMS provider) on starting the application.                                                                                                    |
| 9     | Events                  | <p></p><ul><li>Account Transfer</li><li>Accounting</li><li>Authorization</li><li>Configuration</li><li>Datatable</li><li>Jobs</li><li>Organization</li><li>Portfolio</li><li>Portfolio\_Center</li><li>Portfolio\_Group</li><li>Survey</li><li>Transaction Loan</li><li>Transaction Savings</li><li>XBRL Mapping.</li></ul> | 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.) |
| 10    | Select 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)                                                                                                                                  |
| 11    | Select Action           |                                                                                                                                                                                                                                                                                                                             | For each selected Event and Entity, you have to select the specific action from the drop-down list.                                                                                                                                                                                      |

&#x20;  4\. Click on 'Submit' button to create a "SMS Bridge" hook.

**Associate a UGD template with an SMS Bridge Hook**: [Click Here](http://youtu.be/JxLNy2W8I2U) 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.&#x20;

&#x20;         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.

&#x20;         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.
