Type alias NewConversationInterceptor

NewConversationInterceptor: ((conversationType, visitorData?, recipient?) => Promise<String | NewConversationInterceptorResult>)

Type declaration

    • (conversationType, visitorData?, recipient?): Promise<String | NewConversationInterceptorResult>
    • Interceptor function which is called every time a new conversation is started from the UI or JS API.

      Starting the conversation is deferred until the Promise returned by this interceptor resolves:

      • If the interceptor rejects the Promise, starting the conversation will be cancelled.
      • If the interceptor resolves the Promise with a String, the value of the String will be used and set as "visitorData" for the conversation created.
      • If the interceptor resolves the Promise with a NewConversationInterceptorResult, the values from it will be used for the "visitorData" and the "recipient" for the conversation created.
      • If the resolved value is undefined, the value passed into the UnbluApi.startConversation method will be used.
      • If the resolved value is set to null, any value passed into UnbluApi.startConversation will be discarded.
      • If the resolved value is neither a NewConversationInterceptorResult, nor a String, nor undefined, the conversation is started without any visitorData.
      • If the interceptor resolves the Promise with something other than a NewConversationInterceptorResult or a String, the conversation is started without any visitorData.

      Any values of NewConversationInterceptorResult that are undefined are replaced by the corresponding values passed to UnbluApi.startConversation. Any values of NewConversationInterceptorResult that are null discard the corresponding values passed to UnbluApi.startConversation.

      Parameters

      • conversationType: ConversationType

        The type of the conversation being started.

      • Optional visitorData: String

        Optional visitorData, only present if passed to the UnbluApi.startConversation method

      • Optional recipient: NewConversationRecipient

        Optional recipient, only present if passed to the UnbluApi.startConversation method

      Returns Promise<String | NewConversationInterceptorResult>

      A Promise deferring the start of the conversation until it resolves.