ZohoSalesIQ.Chat.startWithTrigger()

The ZohoSalesIQ.Chat.startWithTrigger() API allows initiating a chatbot-triggered chat or using the specified chat ID.

Note: 

  • This API is supported from version 9.3.0.
  • For this API to work, ensure the bot trigger is set (Settings > Zobot > Select the bot > Bot Configuration > When the bot should initiate the chat and enable > Performs a custom action) or trigger is set (Settings > Triggers > Initiate the trigger when the visitor > Performs a custom action).
  • When the user matches the trigger criteria, this API immediately opens the chat window, bypassing any configured delay or trigger time.
  • If you want to use the "Invoke JS API" trigger type based on a custom action or specific timing, consider using the performCustomAction() API instead.

Parameters

  • actionName (Optional) - The name of the custom action that should be executed during chat start.
  • chatID (Optional) - Unique ID of the conversation to trigger a chat.
  • department (Optional) - Department to which the chat should be routed.
  • completion (Optional) - The callback to get the result.

Syntax

CopiedZohoSalesIQ.Chat.startWithTrigger(actionName: String, chatID: String? =nil , department: String? = nil, completion: ZSIQResultCompletionBlock? = nil)

//The syntax (supported on the v9.1.0) is deprecated
@objc static public func startWithTrigger(chatID: String? = nil, department: String? = nil, completion: ZSIQResultCompletionBlock? = nil)

Example

Copied ZohoSalesIQ.Chat.startWithTrigger(actionName: "product_inquiry", chatID: "001", department: "Sales") { chat, error in
          if let chat = chat {
              print("Chat started with ID: \(chat.id)")
          } else if let error = error {
              print("Failed to start chat: \(error.localizedDescription)")
          }
 }