06-07-2022 06:30 AM
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.
Solved! Go to Solution.
06-07-2022 07:20 AM
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.
06-07-2022 07:20 AM
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.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide