Skip to content
Open
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
10 changes: 6 additions & 4 deletions app/src/main/java/com/ncp/ai/demo/process/ChatbotProc.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.net.URLEncoder;
import java.security.Timestamp;
import java.util.Date;
import java.util.UUID;

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
Expand All @@ -35,8 +36,9 @@ public static String main(String voiceMessage, String apiURL, String secretKey)
//String apiURL = "https://ex9av8bv0e.apigw.ntruss.com/custom_chatbot/prod/";

URL url = new URL(apiURL);

String message = getReqMessage(voiceMessage);
// userId is a unique code for each chat user, not a fixed value, recommend use UUID. use different id for each user could help you to split chat history for users.
String userId = UUID.randomUUID().toString();
String message = getReqMessage(voiceMessage, userId);
System.out.println("##" + message);

String encodeBase64String = makeSignature(message, secretKey);
Expand Down Expand Up @@ -103,7 +105,7 @@ public static String makeSignature(String message, String secretKey) {

}

public static String getReqMessage(String voiceMessage) {
public static String getReqMessage(String voiceMessage, String userId) {

String requestBody = "";

Expand All @@ -116,7 +118,7 @@ public static String getReqMessage(String voiceMessage) {
System.out.println("##"+timestamp);

obj.put("version", "v2");
obj.put("userId", "U47b00b58c90f8e47428af8b7bddc1231heo2");
obj.put("userId", userId);
obj.put("timestamp", timestamp);

JSONObject bubbles_obj = new JSONObject();
Expand Down