Lua Requires Chilkat v11.0.0+
Lua
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 Lua Downloads
local chilkat = require("chilkat")
-- Assumes Chilkat is unlocked. See Global Unlock Sample.
local http = chilkat.Http.new()
http.require_ssl_cert_verify = true
-- These values come from the waiting session and its configured result branch.
http:set_request_header("reference", "WAITING_SESSION_UUID")
http:set_request_header("result", "invoice_ready")
local data = chilkat.JsonObject.new()
data:update_string("invoiceNumber", "INV-1042")
local resp = chilkat.HttpResponse.new()
local sent = http:http_json("POST", "https://flow-callback.clickatell.com/chat/callback", data, "application/json", resp)
if resp.status_code == 204 then
print("Clickatell already processed this reference.")
return
end
if (sent) and (resp.status_code == 202) then
print("Invoice data accepted for the waiting conversation.")
return
end
if resp.status_code == 0 then
print("No response. Keep the same reference if the job retries.")
return
end
print("Chat Flow returned HTTP " .. resp.status_code)
if (resp.status_code == 400) or (resp.status_code == 410) then
print("Check the reference, result and whether the session is still waiting.")
end