Type Alias OnMessageArgs

OnMessageArgs: {
    Whatsapp: InstanceType<typeof WhatsAppAPI>;
    from: string;
    message: ServerMessage;
    name?: string;
    offload: typeof offload;
    phoneID: string;
    raw: PostData;
    reply: ((response: ClientMessage, context?: boolean, biz_opaque_callback_data?: string) => Promise<ServerMessageResponse | Response>);
}

Type declaration

  • Whatsapp: InstanceType<typeof WhatsAppAPI>

    The WhatsAppAPI instance that emitted the event

  • from: string

    The user's phone number

  • message: ServerMessage

    The messages object

  • Optionalname?: string

    The username

  • offload: typeof offload

    Utility function for offloading code from the main thread, useful for long running tasks such as AI generation

  • phoneID: string

    The bot's phoneID

  • raw: PostData

    The raw data from the API

  • reply: ((response: ClientMessage, context?: boolean, biz_opaque_callback_data?: string) => Promise<ServerMessageResponse | Response>)

    A method to easily reply to the user who sent the message

      • (response, context?, biz_opaque_callback_data?): Promise<ServerMessageResponse | Response>
      • Parameters

        • response: ClientMessage

          The message to send as a reply

        • Optionalcontext: boolean

          Wether to mention the current message, defaults to false

        • Optionalbiz_opaque_callback_data: string

          An arbitrary 512B string, useful for tracking

        Returns Promise<ServerMessageResponse | Response>

        The WhatsAppAPI.sendMessage return value