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.
- 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
-
Clone the repository
git clone https://github.com/libardolara/assistant-ms-chat-integration.git
-
Install modules
npm install
-
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=
-
Install and run Bot Framework Emulator
-
Run your bot at the command line:
npm start
-
Open a new bot on Bot Framework Emulator, point it to endpoint
http://localhost:3978/api/messages
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.
-
Install ngrok and run - point to port 3978
- You will need to sign in to setup.
ngrok http --host-header=rewrite 3978
-
Create Bot Framework registration resource in Azure
- Use the current
https
URL you were given by running ngrok. Append with the path/api/messages
used by this sample - Ensure that you've enabled the Teams Channel
- If you don't have an Azure account you can use this Bot Framework registration
- Use the current
-
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.) -
This step is specific to Teams.
- Edit the
manifest.json
contained in theteamsAppManifest
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 themanifest.json
) - Zip up the contents of the
teamsAppManifest
folder to create amanifest.zip
- Upload the
manifest.zip
to Teams (in the Apps view click "Upload a custom app")
- Edit the
-
Run your bot at the command line:
npm start
Message the bot and Watson Assistant will respond.
Learn how to deploy this application on IBM Cloud Code Engine