api-ai-cocoa-swift icon indicating copy to clipboard operation
api-ai-cocoa-swift copied to clipboard

missing elements in SDK

Open iNishantKhare opened this issue 7 years ago • 3 comments

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

iNishantKhare avatar Jul 11 '17 03:07 iNishantKhare

I have the same problem

ozanpekmezci avatar Jul 16 '17 14:07 ozanpekmezci

I am facing the same problem, Xcode Version 13.2.1 (13C100)

ankita240491 avatar Mar 22 '23 07:03 ankita240491

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
    )
}

ankita240491 avatar Mar 22 '23 09:03 ankita240491