Unity sending messages directly

Original Discord Post by michael_34322 | 2024-10-29 04:44:40

Good morning, I am currently working on a project using Convai in Unity, and I want to be able to have the user select an option from a canvas with text on it and send it to convai, and finally have my character ai return a response based on that text, is this possible and can I please get some assistance, thank you!

Reply by k3kalinix | 2024-10-29 08:04:40

Hello <@1095034475919966259>,

Yes, you can.

Create UI buttons and call SendTextDataAsync from ConvaiNPC.

public void OnButtonClicked(string text)
{
  await _convaiNPC.SendTextDataAsync(text);
}

Reply by michael_34322 | 2024-10-29 19:46:14

Thank you for this script! Just to clarify would I attach this to the button?

Reply by k3kalinix | 2024-10-29 19:47:33

It’s up to you, you just need to call this line when you click the button.
await _convaiNPC.SendTextDataAsync(text);

Reply by michael_34322 | 2024-10-31 17:58:50

Thank you! <@1023671043287699568> this seems to work. I wanted to follow up with a current issue that I’m having. Anytime I start off my conversation with my Convai Character, regardless of what I say in the first prompt, the response is always “I cannot create content that is explicit or contains vulgar language. Can I help you with something else?” even if i say something simple like “Hello”. is there anyway that I can get rid of this?

Reply by k3kalinix | 2024-11-01 16:55:54

Did you enable the Narrative Design?

Reply by k3kalinix | 2024-11-01 16:56:16

You can edit the backstory.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.