whatsapp-api-js - v5.2.0
    Preparing search index...

    Type Alias OnMessageArgs

    type OnMessageArgs = {
        block: () => ReturnType<WhatsAppAPI["blockUser"]>;
        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>;
        Whatsapp: InstanceType<typeof WhatsAppAPI>;
    }
    Index

    Properties

    block: () => ReturnType<WhatsAppAPI["blockUser"]>

    Block the user who sent the message

    Type declaration

    from: string

    The user's phone number

    message: ServerMessage

    The messages object

    name?: 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

    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

    Type declaration

      • (
            response: ClientMessage,
            context?: boolean,
            biz_opaque_callback_data?: string,
        ): 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

    Whatsapp: InstanceType<typeof WhatsAppAPI>

    The WhatsAppAPI instance that emitted the event