4
votes

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.

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.Parrett Apps

1 Answers

5
votes

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.