api-ai-cocoa-swift
api-ai-cocoa-swift copied to clipboard
missing elements in SDK
Hi,
I am trying to consume the webhook response in my iOS client. I have added "data" and "displayText" elements in web hook and I am trying to use the same in iOS client. However, when I try to use these elements, I get compile time error that these elements don't exist in Fulfillment struct. When I checked the API.AI SDK, I found that only elements available in Fulfillment are "speech" and "messages".
Has anyone faced this issue? Any advice on this will be much appreciated.
Thanks, Nishant
I have the same problem
I am facing the same problem, Xcode Version 13.2.1 (13C100)
I had to replace bellow function
func serialize(_ source: [String : Any]) throws -> QueryResponse {
let identifier: String = try objectForKey("id", dict: source)
let dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: "en_US")
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
guard let timestamp: Date = dateFormatter.date(from: try objectForKey("timestamp", dict: source)) else {
throw SerializeError.typeMismatch("timestamp")
}
let result = try ResultSerializer().serialize(try objectForKey("result", dict: source))
return Destination(
identifier: identifier,
timestamp: timestamp,
result: result
)
}