CiscoDevNet / node-sparkbot

Build Webex ChatBots in JavaScript
https://developer.webex.com/bots.html
MIT License
24 stars 4 forks source link

Bot is responding to its own messages. #2

Closed savi-ganesh closed 5 years ago

savi-ganesh commented 6 years ago

I am implementing a cisco spark bot , which is now known as Webex teams. I am able to send receive simple text message from user. Is there a way to send rich card to user from Bot? I could not find any helpful documentation.

Here is my code I use to interact with bot

     var SparkBot = require("node-sparkbot");

     var SparkAPIWrapper = require("node-sparkclient");
    // Starts your Webhook with default configuration where the SPARK API access 
    token is read from the SPARK_TOKEN env variable 
    var bot = new SparkBot();

    var spark = new SparkAPIWrapper(process.env.SPARK_TOKEN);

   bot.onMessage(function (trigger, message) {
   if (message.personEmail != "mytestbot@webex.bot")

   spark.createMessage(message.roomId, "You said " + message.text, { 
   "markdown": 
    true }, function (err, message) {
    if (err) {
    console.log("WARNING: could not post message to room: " + 
    message.roomId);
    return;
    }
    });
 });

I need to put an extra check to the bot's email with the trigger email to filter out messages from itself. else it goes in the loop and floods the room with circular messages as - image

ObjectIsAdvantag commented 5 years ago

hi @savi-ganesh, could you check you're still having an issue with the latest release of node-sparkbot. Normally, the bot should not respond to itself, as messages are filtered out by the library.

I suggest you try with one of the provided samples in /tests or /quickstart repos with a bot account.

ObjectIsAdvantag commented 5 years ago

Is there a way to send rich card to user from Bot? I could not find any helpful documentation.

Teams API does not support attachement, but should do in a few weeks as announced at Cisco Live San Diego