Extracting Chat/Conversation At Runtime

Original Discord Post by coltonix. | 2024-09-26 19:48:46

Hi Convai, hopefully you could help me with this!

  1. How can I extract the chat btwn the player and Convai NPC (A) during runtime, particularly the user’s voice input in text form?

  2. Additionally, how do I send the entirety of the user’s input all at once to another Convai NPC (B) , so it can analyze the user’s responses?

Appreciate it!

Answer Update:

  1. Discord
  2. Discord

Reply by coltonix. | 2024-09-26 20:07:04

I found these two guys but not sure how they can help

Images:

Reply by k3kalinix | 2024-09-26 20:15:21

Hello <@367438775263035402> :wave:t2:

Reply by coltonix. | 2024-09-26 20:15:44

Hi K3! So nice to see you again!

Reply by k3kalinix | 2024-09-26 20:21:39

You can use the SendPlayerText and SendCharacterText methods in ConvaiChatUIHandler.cs

Images:

Reply by k3kalinix | 2024-09-26 20:24:51

So you can get Chat Messages from this text parameter.

Reply by coltonix. | 2024-09-26 20:32:56

Thank you! But I’d like to send all the player’s messages to another Convai character, how should I do it?

Reply by k3kalinix | 2024-09-26 20:33:27

Images:

Reply by k3kalinix | 2024-09-26 20:33:36

There are two ways.

Reply by k3kalinix | 2024-09-26 20:34:18

Just you have to call SendTextDataAsync

Reply by coltonix. | 2024-09-26 20:43:41

Where are these two functions? I checked ConvaiNPCManager.cs but couldn’t find .SendTextDataAsync()

Reply by k3kalinix | 2024-09-26 20:44:04

Please check ConvaiNPC.cs

Reply by coltonix. | 2024-09-26 20:45:24

That’s nice! What format will the sent data be in? How should I receive them?

Reply by k3kalinix | 2024-09-26 20:50:11

string

Replying to k3kalinix’s Message

Reply by k3kalinix | 2024-09-26 20:21:39
You can use the SendPlayerText and SendCharacterText methods in ConvaiChatUIHandler.cs

Reply by k3kalinix | 2024-09-26 20:50:23

you can use this text parameter

Reply by coltonix. | 2024-09-26 20:59:51

Forgive me I am still trying to understand how exactly to utilize the function.

So to extract the all the messages that the player sent to NPC_A, do I just have to call NPC_A.SendTextDataAsync() at the end of the conversation? How do I get the string text data in a json file (if this is necessary)? Because I don’t understand where the messages are sent to when NPC_A.SendTextDataAsync() is called. I just want to keep those messages, so that it can become the input for NPC_B

Reply by k3kalinix | 2024-09-26 21:02:03

Ok, I suggest you do some research on the internet for this.

You can get text messages from ConvaiChatUIHandler.cs (SendPlayerText or SendCharacterText methods)

You can do whatever you want with this text parameter. It’s up to you.

Reply by k3kalinix | 2024-09-26 21:02:43

You don’t need to convert to JSON.

Reply by k3kalinix | 2024-09-26 21:03:39

When you get this text message,

just you need to call NPC_B.TextSendDataAsync(text)

Reply by coltonix. | 2024-09-26 21:23:44

Got it! Let me try it and come back to you later :ok_hand: