case 1: When single recipient_email is passed i.e direct message:
Output:
Explaination:
Here, for Single Email, string will be be passed as usual.
if isinstance(recipient_email, str):
if recipient_email is not None:
result = sc.api_call("users.lookupByEmail", email=recipient_email)
# log.info(f'Slack user info for {email}', result)
if result['ok'] is True and 'error' not in result:
user = result['user']
channel_id = user['id']
else:
log.error(f'Cannot identify Slack user for email {recipient_email}')
return None
case 2: When more than one recipient_email is passed i.e group slack creation:
Output:
Explaination:
If we get a list of emails, we need to iterate and get userId for each email and store it in as a list and then send all the ids as string by calling an API.
for email in recipient_email:
response = sc.api_call("users.lookupByEmail", email=email)
if not response['ok']:
log.error(f'Cannot identify Slack user for email {email}')
continue
users.append(response['user']['id'])
user_ids = ",".join(users)
result = sc.api_call("conversations.open", users=user_ids)
Slack Group Messages
case 1: When single recipient_email is passed i.e direct message:
Output:
Explaination: Here, for Single Email, string will be be passed as usual.
case 2: When more than one recipient_email is passed i.e group slack creation:
Output:
Explaination: If we get a list of emails, we need to iterate and get userId for each email and store it in as a list and then send all the ids as string by calling an API.