cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3119
Views
2
Helpful
14
Replies

send instant message to chat room

dgfsgdgf
Level 1
Level 1

Hello,

I am trying to send an instant message to a Jabber chat room using a simple bot.

It works perfectly fine if I send the message to a single user but not when sending to a group.

    bot.say(message = {

        text: 'hi',

        user: 'room@domain.name.com',

        group: true,

    }

Here is the code that fails to send the message. My bot is part of the chat room I am sending to.

Whats interesting is that the following piece of code works perfectly fine to regular users.

    bot.say(message = {

        text: 'hi',

        user: 'name@domain.name.

    }

Thanks in advance and best regards Jan

14 Replies 14

xinpa
Cisco Employee
Cisco Employee

Use below code to send message to a pchat room.

bot.say(message = {
  text
: 'hi',
  user
: 'j4wteam77161840418404@conference-1-standalonecluster.alpha-cup.cisco.com',
  
group: true,
  
});

Make sure you have add this bot into the room. The room id is from room information of the pchat room. Remove im: when you copy room link to the code.

Room.png

That's pretty much what I am doing but I don't see the message popping up.

Is there a way I can get some info about what is going wrong?

Can you send us a PRT and your test code for send the message to the chat room?

Thanks

here us my testcode although i have removed the domain and password ofc. It's just a simple script that should write the weekday when being triggered by crontab. Sorry but what is PRT?

const Botkit = require('.../JabberBot.js');

var controller = Botkit({

    json_file_store: './bot_store/'

});

var bot = controller.spawn({

    client: {

        jid: 'user@domain.com',

        password: 'Password',

        host: "domain.com",

        port: 5222

    }

});

function sayMethod() {

    var d = new Date();

    var weekday = new Array(7);

    weekday[0] = "##### SUNDAY #####";

    weekday[1] = "##### MONDAY #####";

    weekday[2] = "##### TUESDAY #####";

    weekday[3] = "##### WEDNESDAY #####";

    weekday[4] = "##### THURSDAY #####";

    weekday[5] = "##### FRIDAY #####";

    weekday[6] = "##### SATURDAY #####";

    var day = weekday[d.getDay()];

    bot.say(message = {

        text: day,

        user: 'room@domain.com',

        group: true

    }

    );

    return true;

}

setInterval((function () {

    if (sayMethod()) {

        console.log("Closing")

        return process.exit();

    }

}), 1000)

please remove this line and try again.


return process.exit();

Hi, I tried and it didn't work. That exact code minus "group: true," works for a regular user. There seems to be something wrong when it's sending the message to a room.

I have just created a new room for testing purposes and I get the same issue. when I press "edit settings" in Pidgin, my jabber client on that particular room I see the following fields.

Room: test

Server: domain.name.com

Handle: myUser

Password:

So I try the following:

bot.say(message={

        text: 'text',

        user: 'test@domain.name.com',

        group: true

});

But nothing happens. I have tried executing the bot.say command in a try catch but there is nothing failing so I cannot get any further information.

You should click button "Copy room link" to get room id. You will get the following id.

im:test582121922919229@conference-1-standalonecluster.alpha-cup.cisco.com

And then when copy it to the user field, you should remove im:

And copy test582121922919229@conference-1-standalonecluster.alpha-cup.cisco.com.

And please make sure remove process.exit(); in your code.

I do not have the option to copy room link in pidgin. What client are you using?

Jabber 11.9.1

dgfsgdgf
Level 1
Level 1

Trying to download the client and I keep getting the error bellow even though I have added my full address. Does it need to be validated on your side or how does it work?

Error

Cannot request association when the profile does not contain a complete and validated address. Please update the address in your profile using Cisco Account Profile.

What server are you using?

dgfsgdgf
Level 1
Level 1

Software Download - Cisco Systems

This one for downloading the client.

https://rpfa.cloudapps.cisco.com/rpfa/profile/profile_management.do

this one for updating my user account.

I mean the IM server you used. If your company use cisco Jabber, you need to deploy cisco IM&P server.