What is the recommended format for using SendTextDataAsync()?

Hi :slight_smile:

I have searched for an answer on this and couldn’t find anything concrete, what is the recommended way to use the SendTextDataAsync() method in ConvaiNPC.cs, for getting the character to say something specific without needing prompting?

I’ve been using convaiNPC.SendTextDataAsync("< speak > Greet the Player using the time of the day, which is " + timeOfDay + “. < speak >”);

(there are no spaces in the speak tags but without them this post auto edits the < and > signs so I inserted spaces)

But it doesn’t work or is unreliable. What am I doing wrong?

(I’m actually slowly replacing Narrative Design triggers and sections which were previously doing this for me, but using < speak > would be better I think?).

Hello @Tyke,

You are using it incorrectly.

<speak> message </speak> should be like this.

/ missing.

1 Like

Thank you!

1 Like

Hey @K3 I’ve noticed something quite cool, if the / is left off the second speak tag, the character interprets what is within the speak tags in their own way, in contrast to repeating what is in the tags verbatim if the / is present. So if the code is :

convaiNPC.SendTextDataAsync(“< speak > You have just entered a luxury home with the Player, it has a marble floor and huge windows giving a great view of the outside (etc etc) < speak >”); (note no slash)

the character will say something like “I am really happy to be with you in this lovely home, with its beautiful views of the outside and marble floors (etc etc)” and then the next time the code is executed they will say something slightly different, so there is no repetition, which is good.

If the code is :

convaiNPC.SendTextDataAsync(“< speak > You have just entered a luxury home with the Player, it has a marble floor and huge windows giving a great view of the outside (etc etc) </ speak >”); (note the / is included)

The character will repeat what’s in the speak tags verbatim which can be repetitive (and in this case it wouldn’t be suitable of course, the string inside the method call should be “I am happy to be with you in this beautiful luxury home (etc etc)”.

It seems leaving the / off the second speak tag makes the character say something as though a Narrative Design section has specified it (where the character adds their own twist to it).

So I’m leaving the many SendTextDataAsync()'s I use without the / on the closing speak tags, because it is only 1 of them doesn’t work without the / and it’s one that executes at the very start of my app, all the others work ok. I will use ND for the speech needed at the start of my app then use speak’s without the / for the rest.

In this case you do not need to use speak tag. The purpose of the Speak Tag is to ensure that the message is spoken verbatim. If you want it to say something different, you can explain it yourself in this text input instead of the speak tag. So expected behavior.

1 Like

Oh so that’s why that is happening, that is very cool to know I can just explain what I want saying and don’t need speak tags at all, very cool, thank you for the explanation :+1:

1 Like

Yes, try it. Try explaining it clearly and concisely.

1 Like