cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2815
Views
5
Helpful
6
Replies

How can a bot send text messages to a random list of users?

peterbailey
Level 1
Level 1

I need a bot I am writing to send a text message to a variable list of users based on logic I have written. I can't find any examples of this type of thing anywhere. Is there a simple way of doing this. I would be executing out of bot that hears a message like "go do some work". Inside the handler for that, I determine the users that should receive a text and then I want to send the same text message to all of them.

 

Is there an example of something like this anywhere, or is there something in the docs that I missed?

 

Thanks,

Peter

 

1 Accepted Solution

Accepted Solutions

That should be quite possible.  If you are already successfully using Botkit, then this should be very easy - just use the 'bot.say()' command, providing the Jabber user ID as the 'channel' parameter: https://botkit.ai/docs/v0/core.html#botsay.  Do this in a loop for each target user...

 

Note, Botkit has just launched a new/refactored version based on the MS bot framework in its 'master' branch in the Botkit repo - however the Jabber functionality has not yet been ported there.  I believe you can still use the 0.7.4 version directly by downloading: https://github.com/howdyai/botkit/releases/tag/v0.7.4

View solution in original post

6 Replies 6

dstaudt
Cisco Employee
Cisco Employee

If you want to send a text meaning to an IP phone's display, see the <ciscoipphoneexecute> object and POSTing messages to phones in the IP Phone Services SDK: https://developer.cisco.com/site/ip-phone-services/

 

If you mean via Webex Teams, there are a number of learning labs that cover chat-ops and automating sending messages here: https://developer.cisco.com/learning/tracks/devnet-express-cloud-collab-it-pro

 

If referring to SMS, you'll need to look to an outside service, something like Twilio...

Thanks for the reply dstaudt.

I'm a total newbie with this stuff, so sorry for dumb questions. I am a javascript programmer and was asked by a friend if I could help him implement a few things, but this environment is something new for me....

 

So, the scenario I am talking about is that my bot will accept a command to do something from a windows jabber client (that part is basically working), and from that transaction, I will decide on several users to message. They are not on windows jabber, but have jabber for android or ios. on their mobile devices.

 

Can I send a text message to this list of users and have it work with their jabber mobile app?

 

Thanks again,

 

Peter

That should be quite possible.  If you are already successfully using Botkit, then this should be very easy - just use the 'bot.say()' command, providing the Jabber user ID as the 'channel' parameter: https://botkit.ai/docs/v0/core.html#botsay.  Do this in a loop for each target user...

 

Note, Botkit has just launched a new/refactored version based on the MS bot framework in its 'master' branch in the Botkit repo - however the Jabber functionality has not yet been ported there.  I believe you can still use the 0.7.4 version directly by downloading: https://github.com/howdyai/botkit/releases/tag/v0.7.4

Thanks again, I''ll try that. Thought it might be something along those lines but it seemed too easy and I was unclear about the channel.

 

Cheers

 

So I am trying this and the code is below. I am not getting any errors on sending, but the users I am targeting for messages are receiving nothing. Is there something else I need to do? 

 

function message_users(bot, users, roomToClean, cleaning_type) {
for (let i = 0; i < users.length; i++ ) {
   let cleaner = users[i] + emailDomain;  // so this is of the form user@domain.com
                                                             // without the /jabber_11352   - part of the resource - should not affect delivery?
   console.log('in message_users - cleaner = ' + cleaner);
   try {
      bot.say(
          {
             text: 'Clean room ' + roomToClean + 'Type: ' + cleaning_type
             channel: cleaner
         }
      );
   }
   catch (err) {
      log_event('Error in message_users: ' + err);
   }
 }
}

Does anyone here know how this works. No errors, but the messages are not received by the intended user - Super frustrating...