Create Your Own OneDrive Bot Integrated with Webex
Create Your Own OneDrive Bot Integrated with Webex
This article explains how you can create your own Webex-integrated OneDrive bot.
anchorPrerequisites
anchorBefore continuing, you will need access to a few developer resources and the Node.js framework:
- Microsoft Developer Account: You'll need to apply for a developer account to get access to the APIs available on the Microsoft Portal: https://signup.live.com/.
- Cisco Webex Account: You'll need a Webex developer account if you don’t have one already. You can create one on the Webex Developer Portal: https://developer.webex.com/.
- Node.js: To create the Webex bot, you’ll be leveraging the Webex Node Bot framework. Make sure you’ve got Node.js installed on your platform of choice.
anchorBuild the Bot
anchorOnce you have your accounts set up and Node.js installed, follow these steps to create your own OneDrive bot:
- Sign into the Azure portal with your Microsoft account that has Azure Active Directory privileges.
- In the Azure portal, search for and select Azure Active Directory.
- In the left pane, under Manage, select App registrations.
- Select New registration at the top of the page.
- Fill in the following registration details:
- Name: Choose a name for your application (for example,
OneDrive OAuth App
). - Supported account types: Select the accounts you require from any organizational directory or personal Microsoft accounts (This will allow you to access OneDrive data across all types of users).
- Redirect URI: Select Web and provide a URI where you will receive the authorization code after login.
- Name: Choose a name for your application (for example,
- Select Register to create the app.
- Navigate to the app's API permissions section in the Azure portal.
- Select Add a permission and then select Microsoft Graph.
- Search for and add the following scopes:
files.read
,offline_access
. - In Certificates & secrets, select New client secret:
- Add a description and set an expiration for the secret.
- Copy the client secret and save it securely, (you can’t retrieve it later).
- In the Overview section, copy the Application (client) ID and Directory (tenant) ID.
- Implement the OAuth Flow in Your App:
- Retrieve an authorization code from the user: Use the app you created above to authenticate the user. You will be redirected to a login/authorization page (hosted by Microsoft) and prompted to sign in and consent to the permissions your app needs. Once permission is granted, Microsoft will direct back to your app with an authorization code.
- Exchange the authorization code for an access token: Your app sends this authorization code to Microsoft’s server in exchange for an access token and refresh token. The access token is what your app uses to authenticate API requests.
- Use the token to interact with the Microsoft Graph API: Now that your app has the access token, it can use it to make authorized requests to the Microsoft Graph API, which allows you to access data from Microsoft services on behalf of the user.
- Log in to Webex for Developers.
- Create your Webex bot at: https://developer.webex.com/my-apps/new/bot.
- Note down the bot's access token, which you'll use to make API requests.
anchorUse the Webex Node Bot Framework
anchorTo simplify the creation of your bot, you can use the Webex Node Bot Framework available on GitHub. This framework provides a robust and easy to use platform for handling bot interactions:
For any queries related to bot framework you can join the following Webex space: Webex-Node-Bot-Framework Support.
anchorAdditional Resources
anchorFor more information on OneDrive and Webex, see:
- OneDrive API Documentation: https://learn.microsoft.com/en-us/graph/api/resources/onedrive?view=graph-rest-1.0.
- Webex API Documentation: https://developer.webex.com/docs.