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

AutoIt
;  Assumes Chilkat is unlocked. See Global Unlock Sample.
$oHttp = ObjCreate("Chilkat.Http")
$oHttp.RequireSslCertVerify = True

;  These values come from the waiting session and its configured result branch.
$oHttp.SetRequestHeader "reference","WAITING_SESSION_UUID"
$oHttp.SetRequestHeader "result","invoice_ready"
$oData = ObjCreate("Chilkat.JsonObject")
$oData.UpdateString("invoiceNumber","INV-1042")
$oResp = ObjCreate("Chilkat.HttpResponse")
Local $bSent = $oHttp.HttpJson("POST","https://flow-callback.clickatell.com/chat/callback",$oData,"application/json",$oResp)
If ($oResp.StatusCode = 204) Then
    ConsoleWrite("Clickatell already processed this reference." & @CRLF)
    Exit
EndIf

If (($bSent = True) And ($oResp.StatusCode = 202)) Then
    ConsoleWrite("Invoice data accepted for the waiting conversation." & @CRLF)
    Exit
EndIf

If ($oResp.StatusCode = 0) Then
    ConsoleWrite("No response. Keep the same reference if the job retries." & @CRLF)
    Exit
EndIf

ConsoleWrite("Chat Flow returned HTTP " & $oResp.StatusCode & @CRLF)
If (($oResp.StatusCode = 400) Or ($oResp.StatusCode = 410)) Then
    ConsoleWrite("Check the reference, result and whether the session is still waiting." & @CRLF)
EndIf