Skip to content

Instantly share code, notes, and snippets.

@phpmaps
Last active October 7, 2022 01:16
Show Gist options
  • Select an option

  • Save phpmaps/a6c7a9f7179cab251d6699c4c9513b41 to your computer and use it in GitHub Desktop.

Select an option

Save phpmaps/a6c7a9f7179cab251d6699c4c9513b41 to your computer and use it in GitHub Desktop.
Incode Web Hook Events

Additional Web Hook Reference

Doc site: https://docs.incode.com/docs/omni-api/api/web-hooks#notify-onboarding-status-changed

Here is an example web hook payload from Incode.

{
    "interviewId": "fslksdfkljdsljdfs",
    "externalId": "012292928722",
    "onboardingStatus": "MANUAL_REVIEW_APPROVED"
}

Per the flow configuration change, the new meaningful events will be:

  • MANUAL_REVIEW_APPROVED
  • MANUAL_REVIEW_REJECTED

Possible onboardingStatus values are:

  • UNKNOWN
  • ID_VALIDATION_FINISHED
  • POST_PROCESSING_FINISHED
  • FACE_VALIDATION_FINISHED
  • GOVERNMENT_VALIDATION_FINISHED
  • ONBOARDING_FINISHED
  • MANUAL_REVIEW_APPROVED
  • MANUAL_REVIEW_REJECTED

https://docs.incode.com/docs/omni-api/api/web-hooks#notify-onboarding-status-changed

@phpmaps

phpmaps commented Oct 7, 2022

Copy link
Copy Markdown
Author

Web Hook Reference - Handle manual review changes as needed (code snippet)

import { Context, APIGatewayProxyResult, APIGatewayEvent } from 'aws-lambda';
import { logger } from './helpers/logger';
import { IWebHookParams } from './interfaces';
import { SMSFlow } from './sms-flow';

interface IncodeWebHookEvent extends APIGatewayEvent {
    interviewId: string;
    externalId: string;
    onboardingStatus: string;
}

exports.handler = async (event: IncodeWebHookEvent, context: Context) => {

    let webHookParams: IWebHookParams | undefined; 

    if (event?.body !== null) {
        let body = JSON.parse(event.body);
        webHookParams = {
            interviewId: body.interviewId,
            externalId: body.externalId,
            onboardingStatus: body.onboardingStatus,
            requestId: context?.awsRequestId
        };
    }

    logger.warn("Incode WebHook Event Start", webHookParams);

    if (webHookParams?.onboardingStatus === "MANUAL_REVIEW_APPROVED") {

        try {
            const flow = new SMSFlow(webHookParams);
            await flow.run();

        } catch (error) {
            logger.error("Incode WebHook Error", { msg: "SMSFlow failed to run." });
        }
    }

    logger.warn("Incode WebHook Event End", { requestId: context?.awsRequestId });

    const response = {
        statusCode: 200,
        headers: { 'Content-Type': 'application/json' },
        body: ""
    } as APIGatewayProxyResult;

    return response;
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment