Rust Requires Chilkat v11.0.0+
Rust
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 Rust Downloads
// Assumes Chilkat is unlocked. See Global Unlock Sample.
let http = chilkat::Http::new();
http.set_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");
let data = chilkat::JsonObject::new();
let _ = data.update_string("invoiceNumber", "INV-1042");
let resp = chilkat::HttpResponse::new();
let sent = http.http_json("POST", "https://flow-callback.clickatell.com/chat/callback", &data, "application/json", &resp).is_ok();
if resp.status_code() == 204 {
println!("Clickatell already processed this reference.");
return;
}
if (sent) && (resp.status_code() == 202) {
println!("Invoice data accepted for the waiting conversation.");
return;
}
if resp.status_code() == 0 {
println!("No response. Keep the same reference if the job retries.");
return;
}
println!("Chat Flow returned HTTP {}", resp.status_code());
if (resp.status_code() == 400) || (resp.status_code() == 410) {
println!("Check the reference, result and whether the session is still waiting.");
}