Intro

Hooks supercharge the JAWCE engine. It makes it possible to hook custom additional functionality during message processing.

You want to send a Slack notification when user confirms their order? Add a hook.

How about to dynamically populate a message with some dynamic variables? .. yes .. hooks!

There a number of hooks that you can define in your template, the engine will do its best to handle the rest.

Here i will list some of the "hooks" and the other "fields" or "attributes" you can define in your templates

  • type - type of message to render
  • prop
  • on-receive
  • on-generate
  • validator
  • middleware
  • template
  • params
  • message
  • routes

You can probably guess what other hooks does by their name.

Hooks are segmented into POST or PRE hooks

Pre Hooks#

These are processed BEFORE the message is rendered and send to the user on WhatsApp.

In the order which they are processed

These includes

  • params
  • template
  • on-generate

Post Hooks#

These hooks are processed AFTER the user responds to a message.

In the order which they are processed

  • params
  • validator
  • on-receive
  • middleware
  • prop

REST API Hook Model

All REST API based hooks should accept a HookArgs model

Hook Model: HookArgs