DataFlex Requires Chilkat v11.0.0+
DataFlex
Clickatell Chat Flow: Resume a waiting conversation
See more Clickatell Examples
Use this outbound REST call from a billing job after it generates an invoice. Configure a Wait for Callback node with the same reference UUID supplied to the job and the result value used by the flow. Reuse that UUID for retries. Clickatell hosts the endpoint. The billing job needs no inbound HTTP listener.
Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoHttp
Variant vData
Handle hoData
Boolean iSuccess
Variant vResp
Handle hoResp
Boolean iSent
Integer iTemp1
Integer iTemp2
// Assumes Chilkat is unlocked. See Global Unlock Sample.
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
Set ComRequireSslCertVerify Of hoHttp To True
// These values come from the waiting session and its configured result branch.
Send ComSetRequestHeader To hoHttp "reference" "WAITING_SESSION_UUID"
Send ComSetRequestHeader To hoHttp "result" "invoice_ready"
Get Create (RefClass(cComChilkatJsonObject)) To hoData
If (Not(IsComObjectCreated(hoData))) Begin
Send CreateComObject of hoData
End
Get ComUpdateString Of hoData "invoiceNumber" "INV-1042" To iSuccess
Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
If (Not(IsComObjectCreated(hoResp))) Begin
Send CreateComObject of hoResp
End
Get pvComObject of hoData to vData
Get pvComObject of hoResp to vResp
Get ComHttpJson Of hoHttp "POST" "https://flow-callback.clickatell.com/chat/callback" vData "application/json" vResp To iSent
Get ComStatusCode Of hoResp To iTemp1
If (iTemp1 = 204) Begin
Showln "Clickatell already processed this reference."
Procedure_Return
End
Get ComStatusCode Of hoResp To iTemp1
If ((iSent = True) And (iTemp1 = 202)) Begin
Showln "Invoice data accepted for the waiting conversation."
Procedure_Return
End
Get ComStatusCode Of hoResp To iTemp1
If (iTemp1 = 0) Begin
Showln "No response. Keep the same reference if the job retries."
Procedure_Return
End
Get ComStatusCode Of hoResp To iTemp1
Showln "Chat Flow returned HTTP " iTemp1
Get ComStatusCode Of hoResp To iTemp1
Get ComStatusCode Of hoResp To iTemp2
If ((iTemp1 = 400) Or (iTemp2 = 410)) Begin
Showln "Check the reference, result and whether the session is still waiting."
End
End_Procedure