Closed msdev512 closed 11 months ago
Thank you for contacting us! Any issue or feedback from you is quite important to us. We will do our best to fully respond to your issue as soon as possible. Sometimes additional investigations may be needed, we will usually get back to you within 2 days by adding comments to this issue. Please stay tuned.
@msdev512 , could you please try:
Since your bot works fine in local, you may already done these steps:
So, for remote/production, it's similar:
In addition, please also see our FAQ if there's any known scenario matching your case. Probably you may need to add your own storage (instead of the default local file one) for production environment. Otherwise
Hi, thanks for your guidance. i tried to directly add the app from teams but still not able to receive notification on user end.
in APP Log I also found the following error. is it related to the bot or general error message.
HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory.
Is that 403 related to your curl -l
command? That's fine since both api/messages
and api/notification
APIs by default only support POST
.
Since you are able to connect to the APP log, could you please also check:
POST
request to /api/messages
?
/api/messages
works well (returns 200), any issue when POST
/api/notification
?When i call api/notification the bot is receiving this request and also get the body of notification and go to find target and not able to forward the recieved notification to the user as adaptive card.
In case of api/message endpoint invoke from postman, its giving following error:
HTTP Error 500.0 - Internal Server Error
i provisioned and publish the bot using toolkit if you think this there is the error in bot app configuration then kindly let me know the steps to provision and install this bot app to Teams environment.
For /api/messages
, instead of calling from postman, could you please just chatting with the bot via Teams?
Technically, when typing and messaging the bot via Teams (any text is fine, e.g., "Hello"), Teams will call your bot endpoint /api/messages
. Thus I'd like to check if the connection between Teams and your bot endpoint is established correctly.
Ideally the correct flow could be:
/api/messages
receives some request from Teams/api/notification
Step-2/3 is the key point to be checked.
I sent "hello" from teams and received following error in app log:
HTTP Error 404.0 - Not Found The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
Detailed Error Information: Module IIS Web Core Notification MapRequestHandler Handler StaticFile Error Code 0x80070002 Requested URL https://xxxxxxxxxxbot:80/api/messages Physical Path C:\home\site\wwwroot\api\messages Logon Method Anonymous Logon User Anonymous
It appears to be caused by /api/messages
not working.
Does your code (index.js/ts) looks like:
...
server.post("/api/messages", async (req, res) => {
await notificationApp.requestHandler(req, res, async (context) => {
await teamsBot.run(context);
});
});
...
If so, it means POST /api/messages
should return something, no matter 200 or 400 or 403 or 500, but not 404.
And since your code works well locally, it's more like a deploy issue.
@Siglud - could you please check on this? Customer met 404 on /api/messages
after provisioning and deploying the bot app.
this is my sample code to handle bot notification:
const server = restify.createServer();
server.use(restify.plugins.bodyParser());
server.listen(process.env.port || process.env.PORT || 3978, () => {
console.log(\nBot Started, ${server.name} listening to ${server.url}
);
});
const path = require("path");
console.log(process.env);
server.get( "/auth-:name(start|end).html", restify.plugins.serveStatic({ directory: path.join(__dirname, "public"), }) ); //////////////////////////////////////////////////////////////////////////////////
server.post( "/api/notification", restify.plugins.queryParser(), restify.plugins.bodyParser(), // Add more parsers if needed async (req, res) => {
console.log("Request Recieved on bot sending Adaptive Card");
for (const target of await bot.notification.installations()) {
await target.sendAdaptiveCard(
AdaptiveCards.declare(WelcomeTemplate).render({
title: "Welcome, to Test Bot!",
appName: "This will notify you about your system notification",
description: `You can respond on each notifcation by the selecting available actions on Edit Card.`,
notificationUrl: "https://www.adaptivecards.io/",
})
);
}
res.json({});
} ); ////////////////////////////////////////////////////////////////////////////////////////////////////////// ///Bot Framework message handler. /////////////////////////////////////////////////////////////////////////////////////////////////////////
server.post("/api/messages", async (req, res) => { //return InvokeResponseFactory.textMessage("Action is processed successfully!"); const botmessage = await ActivityHandler(req, res);
//if(botmessage.status== 200) if (botmessage.status == 200) { var botresponse = botmessage.data.message; res.json({ botresponse }); } else { res.json({ botmessage }); } // await bot.requestHandler(req, res); //await messageHandler.apply() });
// server.post("/api/messages", async (req, res) => { // await commandBot.requestHandler(req, res).catch((err) => { // // Error message including "412" means it is waiting for user's consent, which is a normal process of SSO, sholdn't throw this error. // if (!err.message.includes("412")) { // throw err; // } // }); // });
When it run it generate the following app Log. Which means its receiving on notification end but as it try to send adaptive card nothing happen.
Request Recieved on bot sending Adaptive Card
2023-06-08 10:39:54 XXXXXXXXXBOT POST /api/notification X-ARR-LOG-ID=25f7034f-dbb6-431c-9c2a-1cc2e1a701fa 443 - x.xx.xx.xx PostmanRuntime/7.32.2 ARRAffinity=d13c54491b9191fc8d717b4a18e5efc690caa1ca195eae4db49dab28a98d15bb;+ARRAffinitySameSite=d13c54491b9191fc8d717b4a18e5efc690caa1ca195eae4db49dab28a98d15bb - xxxxxxxxxxbot.azurewebsites.net 200 0 0 562 2636 46
TeamsFx SDK's requestHandler(req, res)
should be called in api/messages
to support notification but it seems you commented out that part.
requestHandler
in api/messages
is to record user info as targetnotification.installations
in api/notification
is able to get the target infoThis doc describes "How TeamsFx Notification works"
Thank Dear, i am able to get adaptive card at user end.
Actually the the issue was in custom message handling using requestHandler(req, res).
and is there any way to customize this standard response message: "Your response was sent to the app"
Do you mean this one after clicking button on card?
Currently there's no way to customize it. See MicrosoftDocs/msteams-docs#6112
Ok Dear Thnx for your kind guidance..!
hi,
i have build a notification bot in teams and working fine in local environment but when i deployed it to teams using toolkit provisioning and publishing but this is not able to send notification to user.
With debugging on KUDU, I checked the bot is not able to find target as it should be " const target of await bot.notification.installations()"
As a result the message send to the Bot Messaging End has been received by bot but its not sending to the user.
I used this command on KUDU console curl -I https://ivr-sr-bot.botapps.amat.com/api/messages
and found following Error,
"(28) Failed to connect to ivr-sr-bot.botapps.amat.com port 443 after 21074 ms: Timed out"
Please help me to fix this issue. Thanks