Skip to content

Latest commit

 

History

History

service-desk-sample-bot

ServiceDeskSampleBot

Sample Service Desk Bot

This bot has been created using Bot Framework, it shows how to create a bot capable of performing Service Desk tasks.

Prerequisites

  • Node.js version 8.5 or higher
    # determine node version
    node --version

To run the bot locally

  • Create a .env file locally with the following contents:
    botFilePath="ServiceDeskSampleBot.bot"
    botFileSecret="<SECRET USED TO ENCRYPT THE BOT FILE>"
    PWD_RESET_TENANT_ID="<Tenant of the directory where the bot is able to reset passwords>"
    PWD_RESET_APP_ID="<App ID of the service principal created in the directory where the bot is able to reset passwords> (**)"
    PWD_RESET_APP_SECRET="<Secret of the service principal created in the directory where the bot is able to reset passwords> (**)"
    PWD_RESET_AAD_URL="https://graph.windows.net"
    PWD_RESET_GRAPH_API_VERSION="1.6"
    TICKET_SERVICE_BASE_URL="<URL of the Function deployed to act as the ticket service>"
    TICKET_SERVICE_KEY="<Key of the Function deployed to act as the ticket service>"
    OAUTH_CONFIG_NAME=Name of the OAuth Setting to authenticate the bot (***)
    SMS_SERVICE_URL=<URL of the Logic App capable of sending SMS via Twilio> (****)
    
    • (**) - Requires a Service Principal created and granted admin rights. Check the file powershell/grantAdmin.ps1 on how to add the proper roles.
    • (***) - Requires a Bot Service in Azure and the proper configuration of the Bot App Id and App Secret. Recommended to deploy the bot to Azure following the procedures bellow and then the configuration of an OAuth Setting via the portal and configuration here.
    • (****) - Requires the deployment of a logic app capable of sending messages via Twilio. Deployment procedure described [here].
  • Install modules
    npm install
  • Start the bot
    npm start

Testing the bot using Bot Framework Emulator v4

Bot Framework Emulator is a desktop application that allows bot developers to test and debug their bots on localhost or running remotely through a tunnel.

  • Install the Bot Framework Emulator version 4.2.0 or greater from here

Connect to the bot using Bot Framework Emulator v4

  • Launch Bot Framework Emulator
  • File -> Open Bot Configuration
  • Navigate to ServiceDeskSampleBot folder
  • Select ServiceDeskSampleBot.bot file

Deploy the bot to Azure

Prerequisites

  • [Azure Deployment Prerequisites][41]

Provision a Bot with Azure Bot Service

After creating the bot and testing it locally, you can deploy it to Azure to make it accessible from anywhere. To deploy your bot to Azure:

# login to Azure
az login
# provision Azure Bot Services resources to host your bot
msbot clone services --name "ServiceDeskSampleBot" --code-dir "." --location <azure region like eastus, westus, westus2 etc.> --sdkLanguage "Node" --folder deploymentScripts/msbotClone --verbose

After created the application, add the same application settings as the ones added in the .env to run locally as stated here but this time the settings should be added to the application where the bot was deployed to in Azure.

Publishing Changes to Azure Bot Service

As you make changes to your bot running locally, and want to deploy those change to Azure Bot Service, you can publish those change using either publish.cmd if you are on Windows or ./publish if you are on a non-Windows platform. The following is an example of publishing

# build the bot source code
npm run build
# run the publish helper (non-Windows) to update Azure Bot Service.  Use publish.cmd if running on Windows
./publish

Getting Additional Help with Deploying to Azure

To learn more about deploying a bot to Azure, see Deploy your bot to Azure for a complete list of deployment instructions.

Further reading