Introduction
ThefindOrdersByEmail
function allows you to locate orders associated with a customer by using the provided email address. When executed within the Execute JavaScript block, it checks for the existence of orders in the system and, if found, returns an array containing detailed information about the orders linked to that email — including customer details, purchased items, and payment status.
How to Use
-
First, you will need to use the advanced settings of our WhatsApp messages to request the client’s email, saving the response provided by the client in a variable — in this case,
payload.email
.
findOrdersByEmail
function and search for orders associated with the provided email address.

-
In the Execute JavaScript block, we use the code
payload.orders = await findOrdersByEmail(payload.email)
to retrieve orders associated with the email provided by the client. This way, the email saved in thepayload.email
variable is used by thefindOrdersByEmail
function to query the system, and the result is stored inpayload.orders
as an array containing the orders. -
The search response can subsequently return information about the orders found in the following messages.
Example Code
Example Code
for
and if/else
structures. These commands enable detailed and conditional formatting of the displayed information. To deepen your knowledge about Reportana® Script and explore more examples, please consult the complete documentation: Reportana® Script - Documentation.
Return of the findOrdersByEmail
Function
Data Returned in the Response
The search returns detailed information about the orders, including:- Customer Data: Name, phone, email used to place the order, etc;
- Order Information: Order ID, payment status (e.g., paid, pending), payment method (e.g., boleto, credit card), order creation date, etc;
- Address Data: Billing address and shipping address, including city, state, ZIP code, etc;
- Order Items: Product name, variant (e.g., color), quantity, unit price, product image link, etc;
- Payment Information: Boleto URL, boleto barcode line, due date, Pix copy and paste code, total order value, etc;
- Useful URLs: Order tracking link and any other relevant URLs.