Start new conversation

Starts a new conversation, or starts a new conversation with a message.

Start a new conversation

Kustomer.startNewConversation(afterCreateConversation: { convo in
  print(convo.id)
})

Open a new conversation with an initial message

📘

KUSInitialMessage

This struct takes a string for the "body" of the message and a direction which can be either .agent or .user, depending on which "side" of the conversation you wish the message to appear from.

Use initialMessage to set chat to open with a messages at the start of the conversation.

Kustomer.startNewConversation(
  initialMessage: KUSInitialMessage(body: "Hi, I need help", direction: .user),
  afterCreateConversation: { conversation in
    print("New conversation created. Conversation id is \(conversation.id)")                          
  }, 
  animated: true
)

🚧

Agent initialMessage appears on the mobile chat UI only

If the message you include as the initialMessage is from the .agent direction it will only appear for the mobile chat interface. The messages will not display for the web chat widget.

👍

animated: true vs. animated:false

Pass in animated: false to open a new conversation without the chat history. Otherwise, the chat UI displays the customer chat history before displaying the new conversation.


Did this page help you?