Tcl Requires Chilkat v11.0.0+
Tcl
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 Tcl Downloads
load ./chilkat.dll
# Assumes Chilkat is unlocked. See Global Unlock Sample.
set http [new_CkHttp]
CkHttp_put_RequireSslCertVerify $http 1
# These values come from the waiting session and its configured result branch.
CkHttp_SetRequestHeader $http "reference" "WAITING_SESSION_UUID"
CkHttp_SetRequestHeader $http "result" "invoice_ready"
set data [new_CkJsonObject]
CkJsonObject_UpdateString $data "invoiceNumber" "INV-1042"
set resp [new_CkHttpResponse]
set sent [CkHttp_HttpJson $http "POST" "https://flow-callback.clickatell.com/chat/callback" $data "application/json" $resp]
if {[CkHttpResponse_get_StatusCode $resp] == 204} then {
puts "Clickatell already processed this reference."
delete_CkHttp $http
delete_CkJsonObject $data
delete_CkHttpResponse $resp
exit
}
if {expr [$sent == 1] && [[CkHttpResponse_get_StatusCode $resp] == 202]} then {
puts "Invoice data accepted for the waiting conversation."
delete_CkHttp $http
delete_CkJsonObject $data
delete_CkHttpResponse $resp
exit
}
if {[CkHttpResponse_get_StatusCode $resp] == 0} then {
puts "No response. Keep the same reference if the job retries."
delete_CkHttp $http
delete_CkJsonObject $data
delete_CkHttpResponse $resp
exit
}
puts "Chat Flow returned HTTP [CkHttpResponse_get_StatusCode $resp]"
if {expr [[CkHttpResponse_get_StatusCode $resp] == 400] || [[CkHttpResponse_get_StatusCode $resp] == 410]} then {
puts "Check the reference, result and whether the session is still waiting."
}
delete_CkHttp $http
delete_CkJsonObject $data
delete_CkHttpResponse $resp