문제 설명
Android 애플리케이션에 RASA 챗봇 통합 (Integration of RASA Chatbot on Android Application)
제 질문은 제가 RASA를 사용하여 AI 기반 은행 챗봇을 개발하고 있다는 것입니다. 모바일 애플리케이션(Android)에 배포하거나 통합하는 방법을 알려주실 수 있나요?
미리 감사합니다.
참조 솔루션
방법 1:
I assume you use retrofit/Gson, if not it's easy to get the idea at first you need to retrive JWT token, for that you need to call
@POST("api/auth/jwt")
fun authenticateAsync(@Body authRequest: AuthRequest): Deferred<AuthResponse>
where AuthRequest is
data class AuthRequest(
@SerializedName("conversation_id")
@Expose
val conversation_id: String = UUID.randomUUID().toString(),
@SerializedName("chat_token")
@Expose
val chat_token: String
)
where conversation id is some random string, chat_token is the token when you share the bot, smth like 87f7d34f9aa74d51asdqwe27fac62c44
after getting jwt token you can post messages with
@POST("api/conversations/{conversation_id}/messages?environment=production")
fun postMessageAsync(
@Header("Authorization") token: String,
@Path("conversation_id") conversation_id: String,
@Body messageRequest: MessageRequest
): Deferred<List<ChatMessageResponse>>
where
data class MessageRequest(
@SerializedName("message")
@Expose
val message: String
)
and
data class ChatMessageResponse(
@SerializedName("recipient_id")
@Expose
val recipient_id: String,
@SerializedName("text")
@Expose
val text: String,
@SerializedName("externalFields")
@Expose
val externalFields: List<String>,
@SerializedName("custom")
@Expose
val custom: CustomResponseData? = null
)
Hope it was helpful
(by Afaq Khan、Hakob Hakobyan)