Sample code for 30+ languages & platforms
PowerBuilder Requires Chilkat v11.0.0+

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.

Clickatell API reference

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
oleobject loo_Http
oleobject loo_Data
oleobject loo_Resp
long li_Sent

//  Assumes Chilkat is unlocked. See Global Unlock Sample.
loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if
loo_Http.RequireSslCertVerify = 1

//  These values come from the waiting session and its configured result branch.
loo_Http.SetRequestHeader("reference","WAITING_SESSION_UUID")
loo_Http.SetRequestHeader("result","invoice_ready")
loo_Data = create oleobject
li_rc = loo_Data.ConnectToNewObject("Chilkat.JsonObject")

loo_Data.UpdateString("invoiceNumber","INV-1042")
loo_Resp = create oleobject
li_rc = loo_Resp.ConnectToNewObject("Chilkat.HttpResponse")

li_Sent = loo_Http.HttpJson("POST","https://flow-callback.clickatell.com/chat/callback",loo_Data,"application/json",loo_Resp)
if loo_Resp.StatusCode = 204 then
    Write-Debug "Clickatell already processed this reference."
    destroy loo_Http
    destroy loo_Data
    destroy loo_Resp
    return
end if

if (li_Sent = 1) AND (loo_Resp.StatusCode = 202) then
    Write-Debug "Invoice data accepted for the waiting conversation."
    destroy loo_Http
    destroy loo_Data
    destroy loo_Resp
    return
end if

if loo_Resp.StatusCode = 0 then
    Write-Debug "No response. Keep the same reference if the job retries."
    destroy loo_Http
    destroy loo_Data
    destroy loo_Resp
    return
end if

Write-Debug "Chat Flow returned HTTP " + string(loo_Resp.StatusCode)
if (loo_Resp.StatusCode = 400) OR (loo_Resp.StatusCode = 410) then
    Write-Debug "Check the reference, result and whether the session is still waiting."
end if



destroy loo_Http
destroy loo_Data
destroy loo_Resp