Lahiru Karunaratne
Lahiru Karunaratne

Reputation: 2268

Greet the user with the user's name in chatbot using API.AI

I'm trying to make a chatbot using API.AI with Javascript and JQuery. I need to the following.

Bot: Hi, I'm a chatbot. What's your name?
User: Hi, I'm John Doe
Bot: How can I help you John Doe?

The bot should be able to capture the user's name and should be able to chat with the user by the his/her name. I have tried lots of things but I could't figure out a proper way to implement this.

Upvotes: 1

Views: 2516

Answers (1)

MrEbbinghaus
MrEbbinghaus

Reputation: 1023

That's simple.

  1. User says: "My name is John Doe"
  2. Select "John Doe" and type the entity @sys.given-name.

User says field

  1. Now you can fiddle with this value:

Action parameter field

  1. And you can use it in the response field!

text response field

  1. Profit! You can use an output context to store the name, through your conversation.

context field

You can see this parameter is stored in result -> parameters, as well in result -> context -> user-name -> given name. In order to enhance the lifespan of this context, you either give it a manual high lifespan or better, renew it by using it in other intents as an output. When using it as an input you can limit the user to intents, when they didn't tell you their name.

enter image description here

Upvotes: 2

Related Questions