// Create an instance of APIAction
let apiAction = new APIAction("https://example.com/api", "POST");
// Create an instance of ButtonElement
let submitButton = new ButtonElement("1", apiAction, "Submit");
// Create a new instance of FormMessage
let formMessage = new FormMessage("receiverId", CometChat.RECEIVER_TYPE.USER, "customType", "Title", [], submitButton);
formMessage.setGoalCompletionText("Goal completed");
// Create a FormMessage from JSON
let json = {
receiver: "receiverId",
receiverType: CometChat.RECEIVER_TYPE.USER,
type: "form",
data: {
interactiveData: {
title: "Title",
formFields: [],
submitElement: new ButtonElement("1", new APIAction("https://example.com/api", "POST"), "Submit")
}
}
};
let formMessageFromJSON = FormMessage.fromJSON(json);