Built-in Templates

Prev Next

Narmi Functions comes with several pre-built templates to save development time on common integrations.

Hello World

This is the most basic template, which outputs simple “Hello from Narmi!” text. We recommend starting with this template in order to get familiar with how Narmi Functions works. It shows the basic syntax and format of a Narmi Function JavaScript handler.

  • Technical Details – This function will return a JSON response with two properties—a status code and message.

  • Environment Variables – None

  • Supported Types – This template supports all function types.

Hello World Hosted NAF

This template is a basic example of a statically hosted NAF App that connects to a backend Narmi function to fetch data. For detailed instructions on using this template, go to Create a New Function and NAF App.

  • Technical Details – The contents of the frontend UI are a simple HTML page and JavaScript file. The backend simply returns a greeting message.

    • Additional notes: As an additional step, the dynamic backend Narmi function URL will need to be added to the url variable of the index.js file, and the frontend code will need to be re-uploaded.
  • Environment Variables – None

  • Supported Types – This template supports only NAF-type functions.

Decrypt

This template is a helper module that decrypts environment variables for you. It demonstrates how encrypted and plaintext environment variables can be utilized.

  • Technical Details – This template shows the necessary utility imports and syntax needed to decrypt encrypted environment variables. Note: The utility package does not need to be bundled with your application and is included by default with all Narmi Functions.

  • Environment Variables:

    • MY_NAME – A plaintext environment variable that is returned as part of the response message.
    • MY_SECRET – An encrypted environment variable that needs to be decrypted via a KMS API call before it can be viewed.
  • Supported Types – This template supports all function types.

Slack Notification

Use this template to create generic Slack notifications triggered by system events, such as wire transfers needing review. This function does not interact with the Narmi APIs.
Slack general alert

  • Technical Details – The function executes in two steps:
  1. The webhook request is validated via the webhook secret and ID; these are automatically included under the environment variables NARMI_WEBHOOK_SECRET and NARMI_WEBHOOK_UUID.

  2. A message is sent to the desired Slack channel using an API request to the Slack API.

  • Environment Variables:

    • SLACK_TOKEN – The token of the Slack app that has access to send messages to your desired workspace. For information on setting up a basic Slack app and token, go to this Slack article on basic app setup. You can also reference these Slack instructions on sending messages.

    • SLACK_CHANNEL – The target Slack channel to send the message to

    • STAFF_PORTAL_URL – The root domain of your Admin Platform; this is typically https://staff.yourdomain.com

    • MESSAGE – Add this variable in order to customize the text of the message sent to the Slack channel. If this variable is not added, the default message will be "A user has submitted a transfer, you can view it at ${staffUrl}/users/${body.user_id}"

  • Supported Types – This template supports the webhook function type.

Microsoft Teams Notification

Use this template to create Microsoft Teams notifications for certain user actions, such as wire transfers being created. Leveraging the built-in Incoming Webhook feature of Microsoft Teams, any supported user action can be alerted on in your institution’s Microsoft Teams channels.

Microsoft Teams Notification

Use this template to create Microsoft Teams notifications for certain user actions, such as wire transfers being created. Leveraging the built-in Incoming Webhook feature of Microsoft Teams, any supported user action can be alerted on in your institution’s Microsoft Teams channels.


Watch this demo to see how an ACH transfer requiring manual review triggers a Teams notification.


Your institution is responsible for configuring the Incoming Webhook feature within your Teams organization and providing Narmi with the corresponding HTTPS endpoint. For more information from Microsoft, go to Create an Incoming Webhook and Webhooks and Connectors.
MS teams alert2

  • Technical Details – This function executes in three general steps:
  1. The encrypted environment variables are decrypted using the utility functions which are provided for each function.
  2. The signed headers are generated for the Narmi API request and the user’s information is retrieved from the Narmi API using the provided user_id.
  3. When a notification is triggered, the Narmi Function will perform a POST request to the Webhook’s endpoint, with a valid JSON Payload describing a Microsoft Teams Messaging Card: application/vnd.microsoft.teams.card.o365 connector

The first two steps of this function are fairly universal for webhook functions to retrieve additional information on the user and related resources for the trigger event.

  • Environment Variables:
    • MICROSOFT_URL – The unique webhook URL that is created when you add an Incoming Webhook to a Microsoft Teams channel.

    • API_TOKEN: The token of an access token from your NAF App, which you register in the Admin Platform. The token and parent application must have the scope private_api:user. Go to Manage Access Tokens for more information on tokens.

    • API_SECRET – The Client Secret of the above access token. This is used to sign request headers. The Client Secret will appear onscreen once you complete registration of the NAF App.

    • API_URL – The root domain of your Narmi API; this is typically https://api.yourdomain.com

    • STAFF_URL – The root domain of your Admin Platform; this is typically https://staff.yourdomain.com

    • MESSAGE_TITLE – Add this variable in order to customize the title text of the message sent to the Microsoft Teams channel. If this variable is not added, the default is "Narmi Functions."

    • MESSAGE_BODY – Add this variable in order to customize the body text of the message sent to the Microsoft Teams channel. If this variable is not added, the default is "Received event ${type}"

    • BUTTON_URL (Optional) – This variable overrides the default URL for the notification card's "View on Staff Portal" button. The default link opens to a specific user in the Admin Platform, but you may want to change this depending on the user action. For example, for an ACH transfer review, you may want the button to open the ACH Manager.

  • Supported Types – This template supports the webhook function type.

Account Application State Change (Slack)

Use this template to create Slack notifications when account applications enter a specific state, such as requiring a manual review from a staff member. See "Supported Trigger Events" below for the specific user actions supported by this template.
App State Change alert

  • Technical Details – This function executes in three general steps:
  1. The webhook event is validated, and encrypted environment variables are decrypted using the utility functions that are provided for each function.
  2. The signed headers are generated for the Admin API request, and the application information is retrieved from the Admin API using the application UUID from the webhook.
  3. If the application is in the desired state, a message is sent to the desired Slack channel using an API request to the Slack API.

The first two steps of this function are fairly universal for webhook functions that retrieve additional resource information for the trigger event.

Additional logic will filter out duplicate notifications after the API calls. To correlate the webhook with a specific instance of an application state change, the webhook timestamp and the application status timestamp are compared to ensure they are within 100ms of each other. If they are not, the notification is suppressed.

  • Environment Variables:

    • SLACK_TOKEN – The token of the Slack app that has access to send messages to your desired workspace. For information on setting up a basic Slack app and token, go to this Slack article on basic app setup. You can also reference these Slack instructions on sending messages.
    • SLACK_CHANNEL – The target Slack channel to send the message to
    • STAFF_PORTAL_URL – The root domain of your Admin Platform; this is typically https://staff.yourdomain.com
    • API_TOKEN: The token of an access token from your NAF App, which you register in the Admin Platform. The token and parent application must have the scope private_api:user. Go to Manage Access Tokens for more information on tokens.
    • API_SECRET – The Client Secret of the above access token. This is used to sign request headers. The Client Secret will appear onscreen once you complete registration of the NAF App.
    • API_URL – The root domain of your Narmi API; this is typically https://api.yourdomain.com
  • Supported Types – This template supports the webhook function type.

  • Supported Trigger Events – Only the following trigger events are valid for this template:

    • accountapplication.create
    • accountapplication.update
    • applicant.update
    • applicant.create

Account Application State Change (Teams)

Use this template to create Microsoft Teams notifications when account applications enter a specific state, such as requiring a manual review from a staff member. See "Supported Trigger Events" below for the specific user actions supported by this template.
statechangeteams

Watch this demo to see how an application requiring manual review triggers a Teams notification.

Watch this demo to walk through the set up for this template.

  • Technical Details – This function executes in three general steps:
  1. The webhook event is validated, and encrypted environment variables are decrypted using the utility functions which are provided for each function.
  2. The signed headers are generated for the Admin API request, and the application information is retrieved from the Admin API using the application UUID from the webhook.
  3. If the application is in the desired state, a message is sent to the desired Microsoft Teams channel using an API request to the Teams API.

The first two steps of this function are fairly universal for webhook functions that retrieve additional information about the resources in the trigger event.

Additional logic will filter out duplicate notifications after the API calls. To correlate the webhook with a specific instance of an application state change, the webhook timestamp and the application status timestamp are compared to ensure they are within 100ms of each other. If they are not, the notification is suppressed.

  • Environment Variables:

    • MICROSOFT_URL – The unique webhook URL that is created when you add an Incoming Webhook to a Microsoft Teams channel.
    • STAFF_PORTAL_URL – The root domain of your Admin Platform; this is typically https://staff.yourdomain.com
    • API_TOKEN: The token of an access token from your NAF App, which you register in the Admin Platform. The token and parent application must have the scope private_api:user. Go to Manage Access Tokens for more information on tokens.
    • API_SECRET – The Client Secret of the above access token. This is used to sign request headers. The Client Secret will appear on-screen once you complete registration of the NAF App.
    • API_URL – The root domain of your Narmi API; this is typically https://api.yourdomain.com
  • Supported Types - This template supports the webhook function type.

  • Supported Trigger Events - Only the following trigger events are valid for this template:

    • accountapplication.create
    • accountapplication.update
    • applicant.update
    • applicant.create

Slack and Admin API Integration

Use this template to create Slack notifications triggered by certain user actions, such as wire transfers being created. With this function, any supported user action can be alerted on in your organization’s Slack channels.

  • Technical Details – This function executes in four general steps:
  1. The webhook request is validated via the webhook secret and ID, these are automatically included under the environment variables NARMI_WEBHOOK_SECRET and NARMI_WEBHOOK_UUID.

  2. The encrypted environment var(s) are decrypted using the built-in utility functions bundled with the Narmi function.

  3. The signed headers are generated for the Narmi API request and the user’s information is retrieved from the Narmi API using the provided user_id.

  4. A message is sent to the desired Slack channel using an API request to the Slack API.

The first two steps of this function are fairly universal for webhook functions, as they retrieve additional information about the user and related resources for the trigger event.

  • Environment Variables:

    • SLACK_TOKEN – The token of the Slack app that has access to send messages to your desired workspace. For information on setting up a basic Slack app and token, go to this Slack article on basic app setup.

    • API_TOKEN – The token of an access token from your NAF App, which you register in the Admin Platform. The token and NAF App must have the scope private_api:user. Go to Manage Access Tokens for more information on tokens.

    • API_SECRET – The Client Secret of the above access token. This is used to sign request headers. The Client Secret will appear onscreen once you complete registration of the NAF App.

    • API_ROOT – The root domain of your Narmi API; this is typically https://api.yourdomain.com

    • SLACK_CHANNEL - The target Slack channel to send the message to

  • Supported Types – This template supports the webhook function type.

Narmi Function with the Admin API

Another use case for the Slack and Admin API Integration template is creating a Narmi Function with access to the Admin API, which lets the function retrieve information about any user in the Admin Platform. An example is a webhook function that fetches additional user information from the provided user ID.

For this integration:

  1. Use the Slack and Admin API Integration template.

  2. Register a NAF App – Use private_api:user for the scope and do not make the app public/visible to users. For more information on NAF Apps and instructions on registering one, go to NAF Apps.

  3. Create a new access token with the same scope. Go to Manage Access Tokens for more information. This token with header signing in place will give the Narmi function access to query any user’s data via the Admin API.

NAF Oauth Toolkit

This template utilizes OAuth, which allows the function to make requests on an individual user's behalf.

  • Technical Details – This function should be invoked by the user visiting the Function URL, added via a NAF App. Within the function, OAuth is used by decrypting the token submitted with the user request using the NAF App Client Secret, then authorizing as the user via the Narmi Public API. When registering your NAF App, it should be public/visible to users, and the Function URL should be entered as the Redirect URL. For more information on NAF Apps and instructions on registering one, go to NAF Apps.

  • Environment Variables:

    • CLIENT_ID – The Client ID generated by your NAF App
    • CLIENT_SECRET – The Client Secret that appears on-screen after you register your NAF App
    • API_ROOT – The root domain of your Narmi API; this is typically https://api.yourdomain.com
  • Supported Types – This template supports all function types.

NAF List Accounts

This template uses a static hosted website and NAF OAuth, which allows the function to make GET requests to the /accounts endpoint in the Narmi Public API, returning a list of accounts for the user. This template utilizes the Narmi Design System style.

  • Technical Details – This function should be invoked by the user visiting the hosted static web Frontend URL through a NAF App. This includes a GET request with query string parameters code and the code grant value passed from the NAF. Within the function, OAuth is used by fetching a NAF token that is submitted with the user request using the NAF App Client Secret, and then authorizing as the user via the Narmi Public API. Once the OAuth flow is complete, a GET /accounts Narmi Public API call is made, returning a list of the user’s accounts with Narmi Design System styling.

  • When registering your NAF App, it should be public/visible to users, and the Frontend URL should be entered as the Redirect URL. Within the static hosted site, you should use the Backend URL to make requests with query strings. For more information on NAF Apps and instructions on registering one, go to NAF Apps. For more information on the Narmi Public API, go to Narmi Public API.

  • Environment Variables:

    • CLIENT_ID – The Client ID generated by your NAF App

    • CLIENT_SECRET – The Client Secret that appears on-screen after you register your NAF App

    • API_ROOT – The root domain of your Narmi API; this is typically https://api.yourdomain.com

  • Supported Types – This template supports only the NAF function type.

NAF Endpoints

This template uses a static hosted website and NAF OAuth, which allows the function to make requests to any valid Narmi Public API endpoint, returning the request response’s raw data.

  • Technical Details– This function should be invoked by the user visiting the hosted static web Frontend URL through a NAF App. This includes a GET request with query string parameters code, the code grant value passed from the NAF, and the Narmi Public API endpoint (for example, /cards). Within the function, OAuth is used by fetching a NAF token that is submitted with the user request using the NAF App Client Secret, and then authorizing as the user via the Narmi Public API. Once the Oauth flow is complete, a GET request to the endpoint supplied is sent to Narmi Public API.

  • When registering your NAF App, it should be public/visible to users and the Frontend URL should be entered as the Redirect URL. Within the static hosted site, you should use the Backend URL to make requests with query strings. For more information on NAF Apps and instructions on registering one, go to NAF Apps. For more information on the Narmi Public API, go to Public API Overview.

  • Environment Variables:

    • CLIENT_ID – The Client ID generated by your NAF App

    • CLIENT_SECRET – The Client Secret that appears onscreen after you register your NAF App

    • API_ROOT – The root domain of your Narmi API; this is typically https://api.yourdomain.com

  • Supported Types – This template supports only the NAF function type.