This flow lets you automatically verify receipts sent by leads inside the Datacrazy CRM.
The process works in two parts:
A flow that captures the receipt that was sent
A flow that monitors and sends the receipt to OpenIA to analyze (inside your funnel or a third separate flow. Use tags/additional field in the conditions so they can communicate.
OpenIA then returns:
If the file looks like a PIX receipt or not
The payment amount identified
This kind of automation has been requested more and more, especially in PIX payment funnels.
The process works like this:
Lead sends receipt
CRM captures the attachment
System saves the file URL
A flow monitors the arrival of the receipt using tags
The file is sent to OpenAI
OpenAI replies whether it’s valid and what the amount is
Create a separate flow responsible only for capturing files sent by the lead.
Flow entry:
Message received
Setup:
No filters
Active data source
Add a condition:
Check if the lead has the tag:
verificar comprovanteIf you don't have it, the flow can end.
If you have it, the flow continues.
Now check if the message has a file attached, click on the var { } , now in data input → Message-1 (this is the default name of the message block). If there are more instances, I name them all with the same name!
Field usually used:
attachments.urlIf it doesn't exist, end it.
If it exists, move on.
Now we need to save the file.
Recommended options:
Additional field from Lead
Additional field from Deal
Example:
url_comprovante
If you use Deals, you need to make sure the lead has a deal associated in the CRM.
This depends on your funnel rules.
After saving the file:
Add the tag:
Receipt sentIf the file is .pdf, recommend the lead to send:
Image
Screenshot of the receipt
This really improves the AI analysis.
You can say that you weren’t able to open the PDF, then ask them to send it as an image OR screenshot instead. Works 100%.
At this point, Flow 1 ends.
Now we go back to the main funnel flow.
In the step where the client has to send the proof of payment, set up:
Add tag:
verificar comprovanteCreate an additional numeric field on the lead:
x_loop_timesThis field will control how many times we’ll check if the proof of payment was sent.
Use a <> JavaScript block to control the counter.
The script should:
Read the current value of x_loop_times
If it’s empty or 0 → save 1
If it has a value → increase by +1
Example of the finished code
let x_loop_times = await session.getAdditionalValue('x_loop_times');
// se for null, vazio ou 0 → vira 1
if (!x_loop_times || Number(x_loop_times) === 0) {
x_loop_times = 1;
} else {
// se > 0 → incrementa
x_loop_times = Number(x_loop_times) + 1;
}
// salva novamente no mesmo campo
await session.setAdditionalValue('x_loop_times', x_loop_times);
return {"x_loop_times": x_loop_times}After the JavaScript, add a condition block field has value between two values
//Por exemplo, configure o campo para estar entre 0 e 100.
x_loop_times entre 0 e 100This limits the maximum number of checks.
Add a wait block:
Aguardar 30 segundos ou After that, check:
Lead possui tag "Comprovante enviado"If it doesn't have the tag:
→ the flow keeps waiting and testing again.
If it has the tag:
→ it sends the receipt for AI analysis.
Current setup:
100 verificações
x
30 segundosApproximate total time:
50 minutes
If you want to increase the time, just increase the limit.
Example:
1000 loopsMethod:
POSTURL:
https://api.openai.com/v1/responses{
"model":"gpt-4.1",
"input":[
{
"role":"user",
"content":[
{
"type":"input_text",
"text":"I want to know if this looks like a Pix receipt. Answer valido-nao if it doesn't look like a Pix receipt or valido-sim if it looks like a Pix receipt.\n\nAnswer with:\nvalido-sim\nor\nvalido-nao\n\nDon't send absolutely anything else besides that. Also bring the deposited/sent amount. always use it. The answer needs to be a valid JSON schema, only with the data that was requested"
},
{
"type":"input_image",
"image_url":"${urlComprovante}"
}
]
}
]
}Run tests, see if it works for you, adjust if needed.
The answer must be a valid JSON, containing:
If the receipt looks valid
The amount identified
Expected example:
{
"valido": "sim",
"valor": "150.00"
}Or
{
"valido": "nao",
"valor": null
}With this flow implemented, the system can:
Detect when the client sends a receipt
Identify if it’s a PIX receipt
Extract the amount automatically
Integrate with funnel automations
This lets you create processes like:
Automatic access release
Automatic payment validation
Automatic order approval