AWS Lex: How to display a welcome message when first opened?
Asked Answered
Z

1

6

Is it possible to to display a welcome message in a standalone bot (Node.js)? I would like to have the intent in the builder and invoke in my lambda function or from the front end node app. From the docs i can see that it can be done with postText() or postContent() but not sure how to implement or the best way to go about it.

Edit: The bot is launched from a node app into an iframe whìch then calls the lex api. Based on user input a slot value is returned from lex or from the lambda function.

Zimmermann answered 1/3, 2018 at 18:7 Comment(1)
Can you provide a little more detail on the flow here? End user wants to interact with your bot. We know that node.js and Lex will be used at some point, but it is unclear what the end user does to initially trigger the bot.Gilburt
K
8

You can make an intent with some name (lets say Welcome), give some utterance which will be used to invoke the intent (lets say welcome to chatbot).

Then in your web app onPageLoad you can use PostText function in AWS-SDK to send the exact same utterance.

var params = {
  botAlias: 'alias_of_your_bot',
  botName: 'name_of_your_bot', 
  inputText: 'welcome to chatbot', 
  userId: 'some_user_id',
};
lexruntime.postText(params, function(err, data) {
  if (err) console.log(err, err.stack); 
  else     console.log(data);           
});

Hope it helps.

Kippar answered 2/3, 2018 at 6:16 Comment(2)
Great, thank you, didn't think it would be as simple as this but works great !!!!Zimmermann
This is cool. But this option is somehow looks programmatically for me. AWS needs to add an option in the console instead of this.Vara

© 2022 - 2024 — McMap. All rights reserved.