Capitalize Entity information


(Felipe Marquardt) #1

Is it possible to Capitalize entity´s first letter on a reply message to the user?


(Yoga Ramya Mendu) #2

Hi @felipe,

Currently, we do not have a direct provision to capitalize entity information.
However, you can achieve it by formatting the message node response through javascript.

  • Choose “Javascript” for message node response.
  • Add the following script:

var lower = context.entities.AskForName;
var upper = lower.charAt(0).toUpperCase() + lower.substr(1);

print(“your name is”+ upper);

This would return the name by capitalizing the first letter.

entity1

entity2

Let us know if you need any further clarification on the above.

Regards,
Yoga Ramya.


Do you have pt_br as a language to be used in the bot, already?
(Felipe Marquardt) #3

Thank you @ramyamendu94

It worked. But I Noticed that you used Person Name as Entity Type.

On my Taks it´s not working if the Bot is portuguese only. I have to enable English Language to make it work.

On my Task in Portuguese, the Person name is working only using Patterns defining "my name is * " as a pattern.

That the reason I imagine that the fisrt letter is not capitalized, right?


(Yoga Ramya Mendu) #4

Hi @felipe,

As mentioned in the earlier posts, we have verified with both Portuguese and English.
The names like Marcele in Portuguese are not recognized from the utterance just by selecting the entity type as Person name.
Post: detect user´s name on sentence

With respect to the query in this thread, we hope the given javascript solution worked even for Portuguese as we have tried with Portuguese as default language.

Let us know if you need any further clarification on the above.

Regards,
Yoga Ramya.