dialogflow / api-ai-cocoa-swift

Cocoa Swift library
Apache License 2.0
28 stars 8 forks source link

missing elements in SDK #8

Open iNishantKhare opened 7 years ago

iNishantKhare commented 7 years ago

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

ozanpekmezci commented 7 years ago

I have the same problem

ankita240491 commented 1 year ago

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

ankita240491 commented 1 year ago

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