Algoan

Algoan

  • Documentation
  • Quick Start
  • API Reference

›Implement your resthook

Quick Start

  • Introduction
  • Initialize your chatflow
  • Set up your project
  • Set up your service
  • Implement your resthook

    • Application Service
    • Folder Service
    • Aggregation Service
    • Score Service
    • Signature Service

    Score integration

    • Getting Started
    • With a connector
    • Without a connector
    • Using Algoan Connect

    Analytics API Usage

    • Getting Started

Application Service

Request the user's application

The user's application is filled by information gathered through the chatflow. Your Service is able to request the application at any moment and get the available information at that point of the process. You may request an user's application in order to submit it to a bank's decision or to get further information about it.

Supplement your service

import axios from 'axios';
const BASE_URL = 'https://api.algoan.com';

app.post('/resthook', (req, res) => {
  ...
  // Request the application
  const headers = {Authorization: 'Bearer' + serviceAccountAccessToken};
  const application  = await axios.get(`${BASE_URL}/applications/${id}`, {headers});
});
...

Show your products

You'll need to create a block inside the editor that triggers the event named: products_required. Inside this event payload, there is a applicationId. Application can then be requested by this id in order to get needed information.

Supplement your service

import axios from 'axios';
const BASE_URL = 'https://api.algoan.com';

app.post('/resthook', (req, res) => {
  ...

  if (req.body.eventName === 'products_required') {
    const applicationId = req.body.applicationId;
    const products = [{}];

    const url = `${BASE_URL}/applications/${applicationId}/products`;
    const body = products;
    const headers = {Authorization: 'Bearer' + serviceAccountAccessToken};
    axios.post(url, body, {headers});
  }
});

...

Test your resthook

curl \
  -H "Content-Type: application/json" \
  -X POST "localhost:1337/resthook" \
  -d '{"applicationId": "1234", "eventName": "products_required"}'
# should respond `200`

Furthermore you can adjust the API url to head to a custom server of yours in order to verify your data. This should print:

*** New request incoming ***
URL: applications/1234/products
Headers: auth

Body: [{

}]

Pricings

Once the user has selected the needed product, he can access the available pricings.

You'll need to create a block inside the editor that triggers the event named: pricings_required. Inside this event payload, there is a applicationId. Application can be then requested by that id in order to get needed information to select available pricings (example: loanAmount, birthDate, etc)

Supplement your service

app.post("/resthook", (req, res) => {
  /*
    ...
  */

  if (req.body.eventName === "pricings_required") {
    const applicationId = req.body.applicationId;
    const productId = req.body.productId;
    const headers = { Authorization: "Bearer" + serviceAccountAccessToken };
    const offers = [{}];
    axios.post(
      `${BASE_URL}/applications/${applicationId}/products/${productId}/pricings`,
      offers,
      { headers }
    );
  }
});

Insurances

The user may choose one of the insurances proposed by the partner.

You'll need to create a block inside the editor that triggers the event named: insurances_required. Inside this event payload, there is a applicationId. Application can then be requested by this id in order to get needed information to select suitable available insurances (example: loanAmount, birthDate, etc)

Supplement your service

app.post("/resthook", (req, res) => {
  /*
    ...
  */

  if (req.body.eventName === "insurances_required") {
    const applicationId = req.body.applicationId;
    const productId = req.body.productId;
    const headers = { Authorization: "Bearer" + serviceAccountAccessToken };
    const insurances = [{}];
    axios.post(
      `${BASE_URL}/applications/${applicationId}/products/${productId}/insurances`,
      insurances,
      { headers }
    );
  }
});

Submit the user's application

Once the application is correctly filled through the chatflow, the bank's decision is needed. You'll need to create a block inside the editor that triggers the event named: decision_required. Inside this event payload, there is a applicationId. Application can then be requested by this id and it can be submited to the bank. Application status have to be updated in order to be able to expose the bank's decision through the chatflow.

Supplement your service

app.post("/resthook", (req, res) => {
  if (req.body.eventName === "decision_required") {
    const applicationId = req.body.applicationId;
    const headers = { Authorization: "Bearer" + serviceAccountAccessToken };

    const body = {
      partnerId: "A40B10", // The id of application of partner. We use it to monitor the application afterward
      status: "ACCEPTED",
    };
    axios.patch(`${BASE_URL}/applications/${applicationId}`, body, { headers });
  }
});
← Set up your serviceFolder Service →
  • Request the user's application
    • Supplement your service
  • Show your products
    • Supplement your service
    • Test your resthook
  • Pricings
    • Supplement your service
  • Insurances
    • Supplement your service
  • Submit the user's application
    • Supplement your service
Products
About
Developers
Contact
Privacy policy
©Algoan 2021