Page 1 of 1
Integración con WhatsApp
Posted: Wed Jan 07, 2026 2:32 pm
by mjaviergutierrez
Hola !
Estuve investigando en Post anteriores, sobre la posibilidad de integran mi programa con WhatsApp, puntualmente enviar un documento (factura en PDF), pero NO encuentro nada claro. Alguien tendrá alguna info si existe esta posibilidad ?
Saludos.
Re: Integración con WhatsApp
Posted: Wed Jan 07, 2026 4:34 pm
by serge_girard
Paid option perhaps?
WhatsApp Business API + cURL
Serge
Re: Integración con WhatsApp
Posted: Wed Jan 07, 2026 4:38 pm
by mjaviergutierrez
Hola Serge !
Gracias, me voy a poner a investigar.
Re: Integración con WhatsApp
Posted: Wed Jan 07, 2026 5:04 pm
by franco
Hi MJ, I use HpdfPrint which you can use the same as print. you can also add .jpg pictures
I prints to file
#include <hmg_hpdf.ch>
set HpdfDoc Encoding to "WinAnsiEncoding"
set printer to your invoice number +".pdf" to print to file for emailing.
@10,20 HpdPrint Customer->Name size 10
Give it a try. I think everything you need is here.
Sorry
This may not work but has some good ideas I will get back with proper code.
Re: Integración con WhatsApp
Posted: Wed Jan 07, 2026 9:58 pm
by franco
I found this in SAMPLES
You can use a printer instead of file. File is pdf for emailing or printing.
Code: Select all
#include "hmg.ch"
Function Main()
SELECT HPDFDOC "sample.pdf" PAPERLENGTH 300 PAPERWIDTH 300 LOG
START HPDFDOC
START HPDFPAGE
SET HPDFDOC ENCODING TO "WinAnsiEncoding"
@ 10,20 HPDFPRINT "I want Euro sign here: "+CHR(128)
@ 20,20 HPDFPRINT "I want this STRIKEOUT (not working)" STRIKEOUT
@ 18,67 HPDFPRINT "_________" // COLOR { 51, 255, 255 }
@ 20,92 HPDFPRINT "<---- This line was drawing to simulate a baseline (made manually)" SIZE 9 COLOR { 0, 0, 255 }
@ 30,20 HPDFPRINT "I want this italic" ITALIC
@ 40,20 HPDFPRINT "I want this bold" BOLD
@ 50,20 HPDFPRINT "I want this UNDERLINE (not working)" UNDERLINE
@ 50,67 HPDFPRINT "_________" // COLOR { 255, 0, 0 }
@ 52,92 HPDFPRINT "<---- This line was drawing to simulate a baseline (made manually)" SIZE 9 COLOR { 0, 0, 255 }
@ 60,20 HPDFPRINT "I have HMG 3.2.1 (stable) in Courier-Bold" FONT "Courier-Bold"
@ 80, 10 HPDFPRINT "This is a sample Text in default font in ITALIC." ITALIC
@ 90, 10 HPDFPRINT "This is a sample Text in default font in BOLD." BOLD
@ 100, 10 HPDFPRINT "This is a sample Text in Arial or Helvetica font in ITALIC." FONT "aRIAL" SIZE 14 ITALIC
@ 110, 10 HPDFPRINT "This is a sample Text in Arial or Helvetica font in BOLD and ITALIC." FONT "aRIAL" SIZE 14 BOLD ITALIC
*@ 120, 10 hpdfprint image 'img.jpg' TYPE JPG width 40 height 40' size 10 // (((YOU CAN USE IF YOU HAVE A .JPG PICTURE.)))
* @ 120, 10 HPDFPRINT "This is a sample Text in Times-Roman font in ITALIC with size 8" font "TIMES-ROMAN" SIZE 8 ITALIC
@ 135, 200 HPDFPRINT "This is right aligned text" SIZE 14 RIGHT
@ 150, 105 HPDFPRINT "This is center aligned text" COLOR { 255, 0, 0 } CENTER
@ 170, 100 HPDFPRINT "This is text in bigger font size" SIZE 30 COLOR { 255, 0, 0 }
@ 190, 10 HPDFPRINT "The font is Tscparan.TTF" size 12
END HPDFPAGE
END HPDFDOC
Execute File 'sample.pdf'
Return Nil
Re: Integración con WhatsApp
Posted: Thu Jan 08, 2026 6:38 am
by mol
Hi Franco!
THX for your samples, but I think, Mr Javier beeds whatsapp integration sample...
Re: Integración con WhatsApp
Posted: Thu Jan 08, 2026 9:35 am
by AUGE_OHR
hi,
here is a older Fivewin Desktop Sample :
(not sure if it still work !)
Code: Select all
// whatsapp app must be installed and opened before running this code
#include "FiveWin.ch"
#define ORANGES "https://www.jesmondfruitbarn.com.au/wp-content/uploads/2016/10/Jesmond-Fruit-Barn-Oranges.jpg"
function Main()
local cPhone := ""
local cMsg := "Hello"
if EDITVARS cPhone, cMsg
SendToWhatsApp( AllTrim( cPhone ), AllTrim( cMsg ), ;
{ "tutor01.prg", "..\bitmaps\007.bmp", ORANGES, ;
"https://www.google.co.in/" } )
endif
return nil
function SendToWhatsApp( cPhone, cMsg, aAttach )
local oShell
local aFiles := {}
local aOthers := {}
if Empty( cPhone ); return .f.; endif
DEFAULT cMsg := "Hello"
if !Empty( aAttach )
if !HB_ISARRAY( aAttach ); aAttach := { aAttach }; endif
AEval( aAttach, {|c| if( HB_ISSTRING( c ) .and. File( c ), ;
AAdd( aFiles, c ), AAdd( aOthers, c ) ) } )
endif
cMsg := StrTran( cMsg, CRLF, "%0D%0A" )
oShell := CreateObject( "WScript.Shell" )
ShellExecute( 0, "Open", "whatsapp://send?phone="+cPhone+"&text="+cMsg )
SysWait( 0.5 )
if !Empty( aFiles )
if FW_CopyToClipBoard( aFiles, 15 )
SysWait( 2 ); oShell:SendKeys( "^v" ); SysWait( 1 )
endif
endif
AEval( aOthers, <|u|
if FW_CopyToClipBoard( u, 2 ) .or. FW_CopyToClipBoard( u )
SysWait( 1 ); oShell:SendKeys( "^v" ); SysWait( 1 )
endif
return nil
> )
oShell:SendKeys("~")
return nil
you need to replace "FW_CopyToClipBoard()"
Re: Integración con WhatsApp
Posted: Thu Jan 08, 2026 9:44 am
by serge_girard
Hi Jimmy, what is/are EDITVARS?
Re: Integración con WhatsApp
Posted: Thu Jan 08, 2026 10:03 am
by serge_girard
I have CHATGPT translated Jimmy's code to HMG and this is the result (WORKING!)
Code: Select all
#include "hmg.ch"
// whatsapp app must be installed and opened before running this code
#define ORANGES "https://www.jesmondfruitbarn.com.au/wp-content/uploads/2016/10/Jesmond-Fruit-Barn-Oranges.jpg"
FUNCTION Main()
LOCAL cPhone := ""
LOCAL cMsg := "Hello"
cPhone := InputBox( "Telefoonnummer", "WhatsApp", "" )
IF Empty( cPhone )
RETURN NIL
ENDIF
cMsg := InputBox( "Bericht", "WhatsApp", "Hello" )
SendToWhatsApp( AllTrim( cPhone ), AllTrim( cMsg ), ;
{ "C:\bols\bols.dbf", ;
"C:\bols\confirmQR.jpg"} )
//ORANGES, ;
//"https://www.google.com/" } )
RETURN NIL
FUNCTION SendToWhatsApp( cPhone, cMsg, aAttach )
LOCAL oShell
LOCAL aFiles := {}
LOCAL aOthers := {}
LOCAL cItem
IF Empty( cPhone )
RETURN .F.
ENDIF
DEFAULT cMsg := "Hello"
IF HB_ISARRAY( aAttach )
FOR EACH cItem IN aAttach
IF HB_ISSTRING( cItem ) .AND. File( cItem )
AAdd( aFiles, cItem )
ELSE
AAdd( aOthers, cItem )
ENDIF
NEXT
ENDIF
cMsg := StrTran( cMsg, CRLF, "%0D%0A" )
// WhatsApp openen
ShellExecute( 0, "open", ;
"whatsapp://send?phone=" + cPhone + "&text=" + cMsg, ;
NIL, NIL, 1 )
hb_idleSleep( 0.5 )
oShell := CreateObject( "WScript.Shell" )
// Bestanden plakken
IF Len( aFiles ) > 0
CopyFilesToClipboard( aFiles )
hb_idleSleep( 2 )
oShell:SendKeys( "^v" )
hb_idleSleep( 1 )
ENDIF
// URL's / tekst
FOR EACH cItem IN aOthers
System.Clipboard := cItem
hb_idleSleep( 1 )
oShell:SendKeys( "^v" )
hb_idleSleep( 1 )
NEXT
// Enter = verzenden
oShell:SendKeys( "~" )
RETURN .T.
FUNCTION CopyFilesToClipboard( aFiles )
LOCAL cList := ""
AEval( aFiles, {|c| cList += '"' + c + '"' + CRLF } )
System.Clipboard := cList
RETURN NIL
Whatsapp app must be installed and opened and logged in before running this code !
Beter solution is:
WhatsApp Business API
Twilio / 360dialog
Via HTTP POST + hbcurl
Re: Integración con WhatsApp
Posted: Thu Jan 08, 2026 5:33 pm
by franco
I never text from my programs, just email. Most people nowadays have email on there phones.
I pdf print to printers or pdf print to file for email. In all my reports I give the option of print to file or print to printer.
I do not use @1,1 print any more. I use @1,1 hpdfprint.
If a person calls my clients using my software for a quote They will make up an estimate while they are on the phone with them.
Then ask them their email address. They then send the quote while on the phone with them. That way if customers
accept the can arrange right away how to the complete the sale. Works pretty well.
Don`t forget I am old school, still haven't figured out sql.
Having a bit of trouble sending daily inventory values to website.