Difference between revisions of "Bot Playground/Events/instant message"

From SmartBots Developers Docs
Jump to: navigation, search
Line 12: Line 12:
 
<syntaxhighlight lang="javascript">
 
<syntaxhighlight lang="javascript">
 
Bot.on("instant_message", function(event) {
 
Bot.on("instant_message", function(event) {
  console.log("bot received an IM:", event);
+
console.log(event.speaker_name + " says: \n" + event.message);
 
});
 
});
 +
 +
console.log("Bot is listening, IM something");
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
{{NavMenu}}
 
{{NavMenu}}

Revision as of 16:55, 29 June 2016

Fires when bot receives a message from another avatar or in-world object.

Reference

This event comes with the following event object:

Variable Required Description
Output:
message The text of the message

Example

Bot.on("instant_message", function(event) {
	console.log(event.speaker_name + " says: \n" + event.message);
});

console.log("Bot is listening, IM something");