User Accounts
Access users connected OAuth accounts from your bots
Bots on the lil’bots platform can access users’ connected accounts like Google, Notion, Spotifty Github and others. This is extremly useful when you want your bots to be able to access users’ data or take action on their behalf via APIs.
Whenever a user installs a bot, they can connect their accounts to the bot. The bot can then access the user’s account data via the accounts
object that is passed to the bot’s main
function, as explained below.
The lil’bots plaform takes care of the OAuth flow and securely stores the user’s access tokens. It also makes sure to refresh the token when necessary so when the bot runs it can just start making API calls, without needing to worry about the OAuth flow.
Specifying Accounts in the Bot Spec
To access user accounts in your bot, you need to specify the accounts that your bot needs access to in the bot spec. This is done by adding an accounts
field to the bot spec, with the list of accounts that the bot needs access to. Each account type is specified by the services main domain.
For example, if your bot needs access to the user’s Google account, you would specify the accounts
field in the bot spec like this:
When the user installs this bot, they will be prompted to connect their Google account (if they haven’t already).
When the bot is called, the accounts
array will be passed to the bot’s main
function, with the user’s access token for the Google account. The bot can then use this access token to make API calls on behalf of the user. For example, this is what the accounts array might look like when passed to the bot’s main
function:
Supported Accounts
The following accounts are supported by the lil’bots platform:
Account Type | Provider | Description |
---|---|---|
google.com | Access the user’s Google account. Built in scope for Gmail, Google Drive, Calendar and other Google services. | |
Notion | notion.so | Access the user’s Notion account |
Spotify | spotify.com | Access the user’s Spotify account |
Github | github.com | Access the user’s Github account. Full admin access to GitHub accounts |
Example - Accessing a User’s Google Calendar Events
Here’s an example of a bot that accesses a user’s Google Calendar events: