Hello World bot example
Check out our Hello World bot example that sends a response to a message and handles an event
Here is a simple bot example written in node.js packaged with npm and serverless. Download the sample.
It has a hardcoded bot definition that includes responding with "World" to a message of "Hello" and responding with the event received to a message of "botecho". The other aspect of this implementation is that it hardcodes the authentication token.
Note
In the real-world, your bot will need to store the token and refresh it to get a new token at least every 90 days. As this part of an implementation would more closely tie this example to a particular runtime ecosystem, we did not include it.
{keyword:"Hello",response: "World"},
{keyword:"Ciao",response: "Mondo"},
{keyword:"Hallo",response: "Welt"},
{keyword:"botecho",response: JSON.stringify(lithiumEvent,null,2)},
In this simple example, the bot ignores if the author is the owner of the message received (this, of course, isn't the best practice and if AGENT is the owner of that author, responding will not succeed).
Updated about 3 years ago