Examples: query, "exact match", wildcard*, wild?ard, wild*rd
Fuzzy search: cake~ (finds cakes, bake)
Term boost: "red velvet"^4, chocolate^2
Field grouping: tags:(+work -"fun-stuff")
Escape special characters +-&|!(){}[]^"~*?:\ - e.g. \+ \* \!
Range search: properties.timestamp:[1587729413488 TO *] (inclusive), properties.title:{A TO Z}(excluding A and Z)
Combinations: chocolate AND vanilla, chocolate OR vanilla, (chocolate OR vanilla) NOT "vanilla pudding"
Field search: properties.title:"The Title" AND text
Answered
How I can get the UID or the email address from @mentioned name in the message recevied by my bot?

Hi Team,

I am developing a bot to collaborate with an external system.
When my bot receives a message with @metioned someone, the bot needs to indentify the user id or the email address of the @mentioned name in order to initiate anothre process in the external system for the @mentioned user.

I think the name, for example, "Seimei Kurosawa" with @mention in the received message is not unique so I cannot identify the exact individual by this name.
Is this correct understanding?

<div data-format="PresentationML" data-version="2.0" class="wysiwyg"><p><span class="entity" data-entity-id="0">@Seimei Kurosawa</span> ...

Is there any way to find the individual identification from @mentioned from the received message or event?

Thanks for your help in advance,
Kuro

  
  
Posted one year ago
Votes Newest

Answers


You can either use the Activities API and specify an @mention argument, or use a manual RealTimeEventListener. The User ID is contained within the event but you'll need an additional call to obtain other user attributes like email address.

Activities API

activities = bdk.activities()
@activities.slash(command = "/hello1 {@user}", mention_bot = False)
async def hello(context: CommandContext):
    user_id = context.arguments.get_mention('user').user_id
    email = (await bdk.users().list_users_by_ids(user_ids=[ user_id ])).users[0].email_address
    await bdk.messages().send_message(context.stream_id, f"User ID is {user_id} {email}")

RealTimeEventListener

datafeed_loop = bdk.datafeed()
class MessageListener(RealTimeEventListener):
    async def on_message_sent(self, initiator: V4Initiator, event: V4MessageSent):
        msg = message_parser.get_text_content_from_message(event.message)
        mentions = message_parser.get_mentions(event.message)
        if (msg.startswith('/hello2') and len(mentions) > 0):
            user_id = mentions[0]
            email = (await bdk.users().list_users_by_ids(user_ids=[ user_id ])).users[0].email_address
            await bdk.messages().send_message(event.message.stream.stream_id, f"User ID is {user_id} {email}")
datafeed_loop.subscribe(MessageListener())
  
  
Posted one year ago
Yong Sheng Tan
39 × 2 Administrator
6K Views
1 Answer
one year ago
one year ago
Tags