/assistant-ms-chat-integration

Integration between Watson Assistant and MS services like Teams and Skype

Primary LanguageJavaScript

Watson Assistant - Microsoft Chat Integration

Based on Bot Framework message reactions bot sample.

This bot has been created using Bot Framework v4, it shows how to create a simple assistant that responds to messages using Watson Assistant's conversational AI. The chat can be integrated into Microsoft Teams, Skype, Cortana and other services managed by Bot Framework.

Prerequisites

  • IBM Cloud account
  • Watson Assistant service
  • Azure account with CosmoDB database named botdocs and a container id bot-storage
  • Microsoft Teams is installed and you have an account (Only for live deployment)
  • NodeJS

Instructions

  1. Clone the repository

    git clone https://github.com/libardolara/assistant-ms-chat-integration.git
  2. Install modules

    npm install
  3. Copy or rename the .env_example file to .env (nothing before the dot) and add your Watson Assistant details, CosmosDb variables and Microsoft Bot app keys.

# Environment variables
MicrosoftAppType=
MicrosoftAppId=
MicrosoftAppPassword=
MicrosoftAppTenantId=
CosmosDbEndpoint=
CosmosDbAuthKey=
CosmosDbDatabaseId="botdocs"
CosmosDbContainerId="bot-storage"

# Watson Assistant Variables
ASSISTANT_APIKEY=
ASSISTANT_ID=
ASSISTANT_URL=

To try this sample locally using Bot Framework Emmulator

  1. Install and run Bot Framework Emulator

  2. Run your bot at the command line:

    npm start
  3. Open a new bot on Bot Framework Emulator, point it to endpoint http://localhost:3978/api/messages

botframework

To try this sample locally using MS Teams

Note these instructions are for running the sample on your local machine, the tunnelling solution is required because the Teams service needs to call into the bot.

  1. Install ngrok and run - point to port 3978

    • You will need to sign in to setup.
    ngrok http --host-header=rewrite 3978
  2. Create Bot Framework registration resource in Azure

  3. Update the .env configuration for the bot to use the Microsoft App Id and App Password from the Bot Framework registration. (Note the App Password is referred to as the "client secret" in the azure portal and you can always create a new client secret anytime.)

  4. This step is specific to Teams.

    • Edit the manifest.json contained in the teamsAppManifest folder to replace your Microsoft App Id (that was created when you registered your bot earlier) everywhere you see the place holder string <<YOUR-MICROSOFT-APP-ID>> (depending on the scenario the Microsoft App Id may occur multiple times in the manifest.json)
    • Zip up the contents of the teamsAppManifest folder to create a manifest.zip
    • Upload the manifest.zip to Teams (in the Apps view click "Upload a custom app")
  5. Run your bot at the command line:

    npm start

Interacting with the bot in Teams

Message the bot and Watson Assistant will respond.

Deploy the bot to IBM Cloud

Learn how to deploy this application on IBM Cloud Code Engine

Further reading