Git Product home page Git Product logo

node-js-teams-bot-with-chatgpt's Introduction

Teams-logo.png Open-AI-logo.png

Introduction

A Teams bot to let you chat with ChatGPT on Teams.

Build and Test

Prerequisites

  1. Install Node.js: Node.js (nodejs.org)
  2. Install Git: Git for Windows
  3. Install VS Code: Visual Studio Code - Code Editing. Redefined
  4. Install Azure Function Extension on VSCode In VSCode, go to extensions and search Azure Function to isntall it: image
  5. Ensure you have a Microsoft 365 account and follow the Teams development document to register an App with bot feature.

image Ensure the below permissions are set and you can add a command to allow users to delete chat history. image Please note the bot id and create a client secret which will be used in later.

Bot Id/MicrosoftAppId You can go to Tools in Teams Developer portal to find the bot you created. image

Client Secret/MicrosoftAppPassword And create a new client secret. image

  1. Ensure you have an Azure subscription to create these resources in one resource group:

How to run it

  1. Open Terminal and clone the project: git clone https://github.com/yangsa666/node-js-teams-bot-with-chatgpt.git.

  2. Open the project folder with VS Code.

    image
  3. Raname local.samplesettings.json to local.settings.json, fill the required information. In this sample, it uses MongoDb to store user's chat history with ChatGPT. If you don't have a MongoDb, you can create one on Azure for test.

    image image

AzureWebJobsStorage: Azure storage account connection string. Create a storage account in Azure Portal and go to Access Key to copy a connection string. image

MicrosoftAppTenantId: Your Azure AD / MIcrosoft Entra Tenant ID.

MicrosoftAppId: Bot Id of the bot you created previously.

MicrosoftAppPassword: Client secret of the bot you created previously.

OPENAI_API_KEY: Your OpenAI API key.

OpenAI_MODEL: Your OpenAI model

MongoDb_Connection_String: The connectionstring of the Azure CosmosDB for Mongo you created previously. image

  1. Open Azure Functions Extension, sign in your Azure subscription account to deploy it in the resource group you created before and upload settings to Azure Functions App. See more details here.

    !!!Note!!! If you're using Azure Open AI API, please switch to AzureOpenAIStack branch. You can switch branch via the steps below in VSCode.

    image

    image

  2. After deploying it, configure the Azure function URL in the Teams bot Endpoint URL in Teams developer portal. You can get Azure Function URL by going to Azure Portal, locate your function app you created in the steps above. Then go to messages function, click Get Function Url button. image

    Then you can go back to Teams Developer portal > Tools > find the bot you created > Configure. In the endpoint address field, fill the Azure Function Url you got. NOTE: Please remove ? in the endpoint address. image

  3. Install or preview the Teams bot app on your teams To export the installation package, you can go to Teams Developer portal > locate your app > Publish > Download the app package. image

    Then you can go to Teams to upload this as a custom app. Reference: https://learn.microsoft.com/en-us/microsoftteams/platform/concepts/deploy-and-publish/apps-upload

  4. Enjoy it by saying hello to the bot.

    image

node-js-teams-bot-with-chatgpt's People

Contributors

yangsa666 avatar

Stargazers

 avatar Tom Ding avatar NaNaBa avatar

Watchers

 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.