Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Ground Controller Lvl 1
Message 1 of 2

How do I look up the bot's user ID from my App

I'm testing out an app that watches for comments from users and replies to them. I accidentally wrote an infinite loop, though, because when the bot posts a comment replying to a user, *that* comment triggers an event, and then the bot replies to itself, which proceeds to loop forever.

 

It seems the right way to get the bot to ignore itself is to have the bot look up its own user ID and then ignore comments from that ID, but I can't find how to look up the bot user ID from within the App API client.

1 Reply
Community Manager
Message 2 of 2

Re: How do I look up the bot's user ID from my App

Virtually all bots that are designed to interact with users need to determine if an action was generated by a user or a bot. This is accomplished by looking at the `user.type` field of a REST API response. If the value is "User" then it was a user. If the value is "Bot", then it was a bot. This way you can avoid responding to all bots, not only your own bot.

 

I hope that helps!