Skip to content

Commit

Permalink
feat(android): adding answer bot initialization and basic opening method
Browse files Browse the repository at this point in the history
  • Loading branch information
mateoguzmana committed Dec 13, 2023
1 parent f85f15b commit 17f480f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions android/src/main/java/com/zendeskunified/ZendeskUnifiedModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import zendesk.support.guide.ViewArticleActivity
import zendesk.support.request.RequestActivity
import zendesk.support.requestlist.RequestListActivity
import zendesk.classic.messaging.MessagingActivity
import zendesk.answerbot.AnswerBotEngine
import zendesk.answerbot.AnswerBot

class ZendeskUnifiedModule(reactContext: ReactApplicationContext) :
ReactContextBaseJavaModule(reactContext) {
Expand Down Expand Up @@ -188,9 +190,17 @@ class ZendeskUnifiedModule(reactContext: ReactApplicationContext) :
)
}

@ReactMethod
fun startAnswerBot(
promise: Promise
) {
startAnswerBot()
}

private fun initializeZendesk(appId: String, clientId: String, zendeskUrl: String) {
Zendesk.INSTANCE.init(context, zendeskUrl, appId, clientId)
Support.INSTANCE.init(Zendesk.INSTANCE)
AnswerBot.INSTANCE.init(Zendesk.INSTANCE, Support.INSTANCE);
}

private fun setAnonymousIdentity(email: String?, name: String?) {
Expand Down Expand Up @@ -369,4 +379,16 @@ class ZendeskUnifiedModule(reactContext: ReactApplicationContext) :
else -> PreChatFormFieldStatus.HIDDEN
}
}

private fun startAnswerBot() {
val answerBotEngine = AnswerBotEngine.engine()
val messagingConfiguration = MessagingActivity.builder()

messagingConfiguration.withEngines(answerBotEngine)

val intent: Intent = messagingConfiguration.intent(context)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK

context.startActivity(intent)
}
}

0 comments on commit 17f480f

Please sign in to comment.