cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
468
Views
1
Helpful
1
Replies

Webex Bot to send private messages after prompt from space?

rekane
Cisco Employee
Cisco Employee

Hi, I'm working on part of a Bot that would send a private message to every member of a space after being prompted in the main space (or on a timed basis). Does anyone have any resources for this? I can only see material for sending a message within a space.

1 Accepted Solution

rekane
Cisco Employee
Cisco Employee

Figured this out. For anyone else who may have the same problem, there is a bot.dm() function which takes the person's ID and the message you'd like to send. Example:

 

bot.webex.memberships.list({roomId: bot.room.id})
.then((memberships) => {
for (const member of memberships.items) {
if (member.personId === bot.person.id) {
// Skip the bot
continue;
}
let displayName = (member.personDisplayName) ? member.personDisplayName : member.personEmail;
bot.dm(member.personId, `Hello ${displayName}, please add your availability`);
}
})
.catch((e) => {
console.error(`Call to sdk.memberships.get() failed: ${e.messages}`);
bot.say('Tried to send reminders, failed');
});

 

This loops through the memberships in a given room/space and sends a direct message to each person.

 

View solution in original post

1 Reply 1

rekane
Cisco Employee
Cisco Employee

Figured this out. For anyone else who may have the same problem, there is a bot.dm() function which takes the person's ID and the message you'd like to send. Example:

 

bot.webex.memberships.list({roomId: bot.room.id})
.then((memberships) => {
for (const member of memberships.items) {
if (member.personId === bot.person.id) {
// Skip the bot
continue;
}
let displayName = (member.personDisplayName) ? member.personDisplayName : member.personEmail;
bot.dm(member.personId, `Hello ${displayName}, please add your availability`);
}
})
.catch((e) => {
console.error(`Call to sdk.memberships.get() failed: ${e.messages}`);
bot.say('Tried to send reminders, failed');
});

 

This loops through the memberships in a given room/space and sends a direct message to each person.

 

Getting Started

Welcome to the Webex Community. This is your home to ask questions, share knowledge, and attend live webinars.