Objective-C Requires Chilkat v11.0.0+
Objective-C
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 Objective-C Downloads
#import <CkoHttp.h>
#import <CkoJsonObject.h>
#import <CkoHttpResponse.h>
// Assumes Chilkat is unlocked. See Global Unlock Sample.
CkoHttp *http = [[CkoHttp alloc] init];
http.RequireSslCertVerify = YES;
// These values come from the waiting session and its configured result branch.
[http SetRequestHeader: @"reference" value: @"WAITING_SESSION_UUID"];
[http SetRequestHeader: @"result" value: @"invoice_ready"];
CkoJsonObject *data = [[CkoJsonObject alloc] init];
[data UpdateString: @"invoiceNumber" value: @"INV-1042"];
CkoHttpResponse *resp = [[CkoHttpResponse alloc] init];
BOOL sent = [http HttpJson: @"POST" url: @"https://flow-callback.clickatell.com/chat/callback" json: data contentType: @"application/json" response: resp];
if ([resp.StatusCode intValue] == 204) {
NSLog(@"%@",@"Clickatell already processed this reference.");
return;
}
if ((sent == YES) && ([resp.StatusCode intValue] == 202)) {
NSLog(@"%@",@"Invoice data accepted for the waiting conversation.");
return;
}
if ([resp.StatusCode intValue] == 0) {
NSLog(@"%@",@"No response. Keep the same reference if the job retries.");
return;
}
NSLog(@"%@%d",@"Chat Flow returned HTTP ",[resp.StatusCode intValue]);
if (([resp.StatusCode intValue] == 400) || ([resp.StatusCode intValue] == 410)) {
NSLog(@"%@",@"Check the reference, result and whether the session is still waiting.");
}