Sample code for 30+ languages & platforms
Visual FoxPro 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 Visual FoxPro Downloads

Visual FoxPro
LOCAL loHttp
LOCAL loData
LOCAL loResp
LOCAL lnSent

*  Assumes Chilkat is unlocked. See Global Unlock Sample.
loHttp = CreateObject('Chilkat.Http')
loHttp.RequireSslCertVerify = 1

*  These values come from the waiting session and its configured result branch.
loHttp.SetRequestHeader("reference","WAITING_SESSION_UUID")
loHttp.SetRequestHeader("result","invoice_ready")
loData = CreateObject('Chilkat.JsonObject')
loData.UpdateString("invoiceNumber","INV-1042")
loResp = CreateObject('Chilkat.HttpResponse')
lnSent = loHttp.HttpJson("POST","https://flow-callback.clickatell.com/chat/callback",loData,"application/json",loResp)
IF (loResp.StatusCode = 204) THEN
    ? "Clickatell already processed this reference."
    RELEASE loHttp
    RELEASE loData
    RELEASE loResp
    CANCEL
ENDIF

IF ((lnSent = 1) AND (loResp.StatusCode = 202)) THEN
    ? "Invoice data accepted for the waiting conversation."
    RELEASE loHttp
    RELEASE loData
    RELEASE loResp
    CANCEL
ENDIF

IF (loResp.StatusCode = 0) THEN
    ? "No response. Keep the same reference if the job retries."
    RELEASE loHttp
    RELEASE loData
    RELEASE loResp
    CANCEL
ENDIF

? "Chat Flow returned HTTP " + STR(loResp.StatusCode)
IF ((loResp.StatusCode = 400) OR (loResp.StatusCode = 410)) THEN
    ? "Check the reference, result and whether the session is still waiting."
ENDIF

RELEASE loHttp
RELEASE loData
RELEASE loResp