let formMessage = InteractiveMessage()
formMessage.messageCategory = .interactive
let jsonString:[String:Any] = [
"goalCompletionText": "Goal completed YAY",
"title":"By ",
"formFields":[
[
"defaultValue" : "",
"elementId" : "element1",
"elementType" : "textInput",
"label" : "Name",
"maxLines" : 1,
"optional" : false
],
[
"action" : [
"actionType" : "urlNavigation",
"url" : "https://www.cometchat.com/"
],
"buttonText" : "About us",
"disableAfterInteracted" : false,
"elementId" : "element9",
"elementType" : "button"
]
],
"submitElement" : [
"action" : [
"actionType" : "apiAction",
"dataKey" : "CometChatData",
"headers" : [
"Content-Type" : "application/json",
"apiKey" : "",
"appId" : "",
"onBehalfOf" : ""
],
"method" : "POST",
"payload" : [
"category" : "message",
"data" : [
"text" : "Thanks For filling the Form!"
],
"receiver" : "",
"receiverType" : "group",
"type" : "text"
] as [String : Any],
"url" : ""
] as [String : Any],
"buttonText" : "Submit",
"disableAfterInteracted" : true,
"elementId" : "element8",
"elementType" : "button"
] as [String : Any]
]
formMessage.interactiveData = jsonString
let goal = InteractionGoal()
goal.elementIds = ["element9","element8"]
goal.interactionType = .allOf
formMessage.interactionGoal = goal
formMessage.allowSenderInteraction = true
formMessage.type = "form"
formMessage.receiverType = .user
formMessage.receiverUid = "cometchat-uid-1"
formMessage.muid = "1697025959995609"
formMessage.senderUid = CometChat.getLoggedInUser()?.uid ?? ""
formMessage.sender = CometChat.getLoggedInUser()