cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
647
Views
0
Helpful
3
Replies

Jabber Bot SDK - make direct_mention detection case-insesitive

WolSen000
Enthusiast
Enthusiast

Hi,

during my trials to get the BOT SDK up and running and creating some Bots I was facing the problem that the Bot didn't act on @BotName (direct_mention) in a group-chat.

During the debugging I found the cause to be the case sensitive search for the jids:

function findBotJid(jid) {

  return jid === bot.client_jid;

}

function IsBotMentioned(message)

{

  let mention_jids = ExtractMentionJids(message);

  if (mention_jids.find(findBotJid))

  {

    return true;

  }

  return false;

}

So if the jid you use to register the Bot is not exactly the same as the one configured on IM&P/CUCM, especially if it differs in upper/lower case letters then the Bot will never trigger for any @mentioned messages.

var bot = botCTRL.spawn({

    client: {

        jid: 'jabberbot@company.com',

        password: 'super-secret',

        host: "im&p-host@company.com",

        port: 5222

        }

});

It took me quite some time to figure this out, especially as I wasn't able to get the group-chat working in the SandBox you provide: NEW Sandbox! Jabber Client 12.0 w/ Jabber Bot SDK!

After I found the problem, I checked the RFCs and other sources on the web, but unfortunately I couldn't get a clear statement if the JIDs are case-sensitive or not.

So you might consider either making the search case-insensitive:

function findBotJid(jid) {

   return jid.toLowerCase() === bot.client_jid.toLowerCase();

}

... or at least adapt the documentation to mention this pitfall.

Besides that it's working great and I like it very much. Will start to code some Bots right away....

Thanks and best regards
Wolfgang

3 Replies 3

dstaudt
Cisco Employee
Cisco Employee

Thanks for reporting this issue, the engineering team has indicated they will be committing a fix shortly.

There's another issue we are experiencing where the TO field is appending a unique identifier and the findBotJid function isn't matching.

Example:
botclientID is testbot@nerdherd.local

the TO field in the message for a direct mention in a chat is coming in as:
to: 'testbot@nerdherd.local/0d2a112473b111ad1f3c7213c3532d5d7f5932ee',

Any thoughts on this?

Jason