Hook Model
Supercharge your template with hooks
Hooks are nothing more than regular Python functions or Java classes.
All hooks should accept HookArg
object parameter.
In JAWCE All class hooks should have a constructor which takes HookArg
model as a parameter.
Hook model
Hook Model: HookArg
public record WaCurrentUser(
String name, // default user display name
String waId, // mobile number
String msgId,
Long timestamp
) {}
public record TemplateDynamicBody(
WebhookResponseMessageType type, // for dynamic template message type
Map<String, Object> payload, // used for `flow` type - initial flow data
Map<String, Object> renderPayload // dynamic template data
) {}
// main model
public class HookArgs {
private WaCurrentUser channelUser;
private String userInput; // user input from whatsapp
private String flow; // flow name for flow template type
private Map<String, Object> additionalData; // mainly for dynamic routing
private TemplateDynamicBody templateDynamicBody; // for templates, dynamic and flow messages
private Map<String, Object> methodArgs; // provided static params defined on template
}
The Hook model contains all the necessary data you can use in your business logic