- handling instatllation
- handling message/commnds reply
- handling Context/interaction
- sending Adaptive card
- updating Adaptive card
- Toggling modal/dialog
- handle multiple bots (add as many in .env file)
-
bot will welcome you
-
also show your email & bot converationID on console. (which you can customize to use later)
e.g. you can store (userEmail, conversationID) of whoever install your bot, then later you can send them messages through bot by using Bot's conversationID based on their email. like sending new update or specific message to your community😊.
-
welcome adaptive card will contain 2 button "hi" and "hello"
-
clicking on "hi" and "hello" from welcome message will open a modal/dialog contains bot commands.
for hi ("bot -greet hi")
for hello ("bot -greet hello")
-
message those commands to bot "bot -greet hello"
-
bot will response with greet and a feedback btn
-
click will open modal/dialog like this
-
clicking submit will close modal and update that adaptive card which you use earlier to open this modal/dialog
note:- you can put anything as bot route keep in mind later, that bot route will define specific dynamic endpoint to you bot.
"http://localhost:3002/template/api/messages/whateverBotRoutOfThatBot"
-
run this template over https (bcs azure/teams support bot to run only for ssl), follow these steps.
-
npm install (all dependencies) In my case I am using pm2 and nginx. after doing
- pm2 start index.js,
- service nginx start,
- pm2 logs
you will see this.
-
copy "https://yourdomain.com/template/api/messages/whateverBotRoutOfThatBot"
-
paste it to bots endpoint configuration
for azure

for teams Dev portal

Connect your app with you bot
-
visit teams app dev portal
-
visit your app
-
open App Features tab and click on Bot
-
choose your bot among other bots
-
select scope also (personal is good for me, so we dont have to install bot every time for each team channels or group
-
save all.
Give you app some important permission like
note :- these permissions let bot/app to use MS graph API, in this template this is only using for gathering user email, when user install bot to perform messaging tasks.
- including handle "message extensions" commented line of code. so you can handle this type of stuff👇
check current conversation isBotsConversation(context) on handleContext file ---------
(
when user perform something in bot's conversation/bot's "1to1" chat
- then bots usually response user in its conversation bcs bot is part of its own conversation)
- but if a user perform bot's tasks out of "1to1" chat, like (message extension in teams) from other conversation/chat, group, channel, etc. then bot doesn't know where to reply ('because bot may not be part of that conversation/chat').
❌❌ until you manually install bot in all chats, group, teams one by one ❌❌ (no way right) but we set our scope only personal
so, preserve the conversation ID manually.
- we have to override that conversation ID with bots conversation id but we cannot find it in context, because we are on other chat/conversation right. so,
- we run isBotsConversation(context) - it tell us we are "user-to-bot" or "user-to-group", "user-to-chat", "user-to-channel", etc
- If we are not inside bot tab, then simply take "userEmail" in this situation.
- and retrive "bot's conversationID" from "database or whatever" where we store (userEmail & Bot's conmversationID) earlier based on "userEmail".
- then replace non bot conversationID with retrieved one.
note:- you can store userEmail & Bot's conmversationID when anyone install your bot after some customization in handleContext/handleInstallation.js file.
summary :- performing "message exention" in bot conversation "user-to-Bot", will give response in that conversation. performing "message exention" in other conversation "group/user-to-other-person", will give response in bot's conversation.
handleContext.js /* async function isBotsConversation(context) { try { const members = await context.adapter.getConversationMembers(context); if (members) { return true; } } catch (error) { return false; } } */
/* const isWeAreInBotsConversation = await isBotsConversation(context); if(isWeAreInBotsConversation === false){ resConvID = await retrieveUsersConversationID(userEmail); conversationID = resConvID.conversationID }
console.log("current Conversation ID : " + conversationID); */
this bot's template is your playground! You can customize it to any level 🚀🤖🤖



















