GithubHelp home page GithubHelp logo

cl1432 / botframework-csharp-approvalbot-sample Goto Github PK

View Code? Open in Web Editor NEW

This project forked from microsoftgraph/botframework-csharp-approvalbot-sample

0.0 0.0 0.0 305 KB

A sample Bot that uses adaptive cards and the .NET Graph SDK to send actionable messages requesting approval to release files on OneDrive.

License: MIT License

C# 99.26% HTML 0.60% ASP.NET 0.14%

botframework-csharp-approvalbot-sample's Introduction

page_type products languages description extensions
sample
office-outlook
office-onedrive
ms-graph
csharp
A sample Bot that uses adaptive cards and the .NET Graph SDK to send actionable messages requesting approval to release files on OneDrive.
contentType technologies services createdDate
samples
Microsoft Graph
Microsoft Bot Framework
Outlook
OneDrive
4/23/2018 12:12:07 PM

Approval Bot Sample

Running locally

Follow these steps to enable running the bot locally for debugging.

Prerequisites

Register the app

  1. Open a browser and navigate to the Azure Active Directory admin center. Login using a Work or School Account.

  2. Select Azure Active Directory in the left-hand navigation, then select App registrations (Preview) under Manage.

    A screenshot of the App registrations

  3. Select New registration. On the Register an application page, set the values as follows.

    • Set a preferred Name e.g. Approval Bot.
    • Set Supported account types to Accounts in any organizational directory.
    • Under Redirect URI, set the first drop-down to Web and set the value to http://localhost:3979/callback.

    A screenshot of the Register an application page

  4. Choose Register. On the Approval Bot page, copy the value of the Application (client) ID and save it, you will need it in the next step.

    A screenshot of the application ID of the new app registration

  5. Select Certificates & secrets under Manage. Select the New client secret button. Enter a value in Description and select one of the options for Expires and choose Add.

    A screenshot of the Add a client secret dialog

  6. Copy the client secret value before you leave this page. You will need it in the next step.

    [!IMPORTANT] This client secret is never shown again, so make sure you copy it now.

    A screenshot of the newly added client secret

Set up the ngrok proxy

You must expose a public HTTPS endpoint to receive notifications from the Bot Framework Emulator. While testing, you can use ngrok to temporarily allow messages from the Bot Framework Emulator to tunnel to a localhost port on your computer.

You can use the ngrok web interface (http://127.0.0.1:4040) to inspect the HTTP traffic that passes through the tunnel. To learn more about using ngrok, see the ngrok website.

  1. Download ngrok for Windows.

  2. Unzip the package and run ngrok.exe.

  3. Run the following command line on the ngrok console:

    ngrok http 3979 --host-header=localhost:3979

    Example command to run in the ngrok console

  4. Copy the HTTPS URL that's shown in the console. You'll use this to configure your NgrokRootUrl in the sample.

    The forwarding HTTPS URL in the ngrok console

    Note: Keep the console open while testing. If you close it, the tunnel also closes and you'll need to generate a new URL and update the sample.

Configure and run the sample

  1. Clone the repository locally.

  2. Make a copy of the ./ApprovalBot/PrivateSettings.example.config file in the same directory, and name the copy PrivateSettings.config.

  3. Open ApprovalBot.sln in Visual Studio, then open the PrivateSettings.config file.

  4. Set the value of MicrosoftAppId to the Application (client) ID you generated in the previous step, and set the value of MicrosoftAppPassword to the secret you generated afterwards.

  5. Paste the ngrok HTTPS URL value copied from the previous step into the value of NgrokRootUrl in PrivateSettings.config, and save your changes.

    IMPORTANT: Leave ngrok running while you run the sample. If you stop ngrok and re-start it, the forwarding URL changes, and you'll need to update the value of NgrokRootUrl.

  6. Start the Azure Cosmos DB Emulator. This needs to be running before you start the sample.

  7. Press F5 to debug the sample.

  8. Run the Bot Framework Emulator. At the top, where it says Enter your endpoint URL, enter https://localhost:3979/api/messages.

  9. That will prompt for app ID and password. Enter your app ID and secret, and leave Locale blank.

  10. Click Connect.

  11. Send hi to confirm the connection.

Limitations when running locally

When running the sample locally, the approval request email that sent is a little different. Because it's not running on a confirmed, registered domain, we must send the message to and from the same account. What that means is that when you get to the point where you request approval, you must include yourself in the list of approvers.

You can include other approvers, but the message they receive won't show the adaptive card. Login to your own mailbox with Outlook to test the adaptive card.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Copyright

Copyright (c) 2019 Microsoft. All rights reserved.

botframework-csharp-approvalbot-sample's People

Contributors

darrelmiller avatar jasonjoh avatar microsoft-github-policy-service[bot] avatar microsoftopensource avatar msftgits avatar nokafor avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.