case 1: When single recipient_email is passed i.e direct message:
Output:
Explaination:
Here, for Single Email, string will be be passed as recipient so, convert it into list.
if isinstance(recipient_email, str):
recipient_email = [recipient_email]
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 recipient so, convert it into list.
if isinstance(recipient_email, str): recipient_email = [recipient_email]
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.