Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ const Search = (props) => {
if (!miawChatRef.current.hasFired && miawChatRef.current.newChatLaunched) {
if (
e.detail.conversationEntry?.sender?.role === 'Chatbot' &&
searchInputRef?.current?.value
searchInputRef?.current?.value &&
window.embeddedservice_bootstrap?.utilAPI
) {
miawChatRef.current.hasFired = true
setTimeout(() => {
Expand All @@ -194,17 +195,21 @@ const Search = (props) => {
}
}, [])
const launchChat = () => {
window.embeddedservice_bootstrap.utilAPI
.launchChat()
.then((successMessage) => {
if (window.embeddedservice_bootstrap?.settings) {
window.embeddedservice_bootstrap.settings.disableStreamingResponses = true
window.embeddedservice_bootstrap.settings.enableUserInputForConversationWithBot = false
}
window.embeddedservice_bootstrap?.utilAPI
?.launchChat()
?.then((successMessage) => {
/* TODO: With the Salesforce Winter '26 release, we will be able to use the
* onEmbeddedMessagingFirstBotMessageSent event instead, and get rid of this logic. */
if (successMessage.includes('Successfully initialized the messaging client')) {
miawChatRef.current.hasFired = false //We want the logic in onEmbeddedMessageSent to happen once per new conversation
miawChatRef.current.newChatLaunched = true
}
})
.catch((err) => {
?.catch((err) => {
console.error('launchChat error', err)
})
}
Expand All @@ -218,7 +223,7 @@ const Search = (props) => {
return
}

if (askAgentOnSearchEnabled && window.embeddedservice_bootstrap) {
if (askAgentOnSearchEnabled && window.embeddedservice_bootstrap?.utilAPI) {
// Add a 500ms delay before sending the message to ensure the experience isn't jarring to the user
setTimeout(() => {
window.embeddedservice_bootstrap.utilAPI
Expand Down
1 change: 1 addition & 0 deletions packages/template-retail-react-app/app/hooks/use-miaw.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const initEmbeddedMessaging = (
) {
window.embeddedservice_bootstrap.settings.language = locale
window.embeddedservice_bootstrap.settings.disableStreamingResponses = true
window.embeddedservice_bootstrap.settings.enableUserInputForConversationWithBot = false
window.embeddedservice_bootstrap.init(
salesforceOrgId,
embeddedServiceDeploymentName,
Expand Down
Loading