I have a published application in the Microsoft App store.
Before heading towards the issue, explain below how it works when the app is installed in the team. So, when the bot/app is added to the team it sends a proactive welcome message inside the team. Below is the code which is responsible for this:
constructor() {
super();
this.onConversationUpdate(async (handler) => {
let activity = handler._activity;
if (activity.membersAdded) {
if (activity.membersAdded[0].id.includes(process.env.MicrosoftAppId)) {
// Send proactive welcome message
}
}
}
}
Keeping in mind when the app is installed/added to a team, definitely there should be handler data with me.
That's the case and it's working fine all over tested in different tenants as well, everything working fine.
But, in one of the tenants, there are 3-4 teams, Installing/adding the app doesn’t trigger the constructor at all. Not even a single log is getting there for me. Strangely, inside the manage team` - App section, I could see the app.
Not sure if is it a bug in MS Teams.
Related
First, there has been plenty written on this subject in the context of WebChat, and there are fixes out there that show implementation. Here's a link that is pretty good:
https://blog.botframework.com/2018/07/12/how-to-properly-send-a-greeting-message-and-common-issues-from-customers/
This problem is NOT a WebChat problem, it's a Direct Line problem that uses a 3rd party named LivePerson to host the bot which lives in Azure, and is connected via Direct Line. Hence, I do not control the client code (like I would if I were writing/hosting the bot using html/JavaScript). However, the take away here is "do not use conversationUpdate", which I am using in my bot, but please read on...
I'm hosting my Microsoft v4 Bot in LivePerson using Direct Line. The bot uses Adaptive Dialogs to welcome the user and ask them a question before the user sends any input using the OnConversationUpdateActivity():
public RootDialog(IConfiguration configuration, IMiddlewareApiFacade middlewareApi, IBotTelemetryClient telemetryClient) : base(nameof(RootDialog))
{
var rootDialog = new AdaptiveDialog(nameof(RootDialog))
{
...
Triggers = new List<OnCondition>()
new OnConversationUpdateActivity()
{
Actions = WelcomeUserSteps("${Greeting()}")
}
...
}
private static List<Dialog> WelcomeUserSteps(string message)
{
return new List<Dialog>()
{
// Iterate through membersAdded list and greet user added to the conversation.
new Foreach()
{
ItemsProperty = "turn.activity.membersAdded",
Actions = new List<Dialog>()
{
// Note: Some channels send two conversation update events - one for the Bot added to the conversation and another for user.
// Filter cases where the bot itself is the recipient of the message.
new IfCondition()
{
Condition = "$foreach.value.name != turn.activity.recipient.name",
Actions = new List<Dialog>()
{
new SendActivity(message),
new BeginDialog(nameof(WelcomeDialog))
}
}
}
}
};
}
}
}
This works fine when running the bot locally using the Emulator or running the bot from Test Web Chat in Azure, but it does not work in LivePerson.
I've successfully hooked up and tested the connection to the bot from LivePerson via Direct Line:
However, when the bot is started, and it's accessed via LivePerson's chat, the welcome message does not fire (there should be a welcome message then a question from the bot where the red square is):
Looking at LivePerson's docs, they have an "The Welcome Event" section that talks about the bot greeting the users for bots configured as as "chat" (which is how this bot is configured in LivePerson)
Looking closer at how a chat is considered started for chat conversation bots, the docs state:
A chat conversation is considered started when the chat is routed to an agent. Best practice is for the agent to provide the first response. In this scenario, there is no text from the consumer to parse, thus the default ‘WELCOME’ event is utilized as a start point for the bot to prompt the user to provide input and progress the conversation. Ensure you have an ‘entry point’ in your bot that responds to the default ‘WELCOME’ action send by a new chat customer.
Then this code:
{
// ...
"type": "message",
"text": "",
"channelData": {
"action": {
"name": "WELCOME"
}
}
}
FYI: an "agent" in the context of LivePerson can mean an actual person OR a bot. Both are considered "agents", and when you add a new agent to LivePerson, one of the types available is "bot". So agent does not mean person in this example.
I'm not too sure how my bot (which uses bot framework v4 and Adaptive Dialogs) needs to be configured/implemented to have an entry point that responds to this WELCOME message.
I do know that I cannot use conversationUpdate (or in adaptive dialog speak, OnConversationUpdateActivity()), but I'm not too sure which adaptive dialog (or otherwise) I need to use somehow intercept the json WELCOME message to sent to my bot by LivePerson... OnEventActivity()? OnMessageActivity()? Something else?
Thanks!
The answer is summed up in the blog post I wrote after I figured it out:
https://www.michaelgmccarthy.com/2021/03/13/sending-a-welcome-message-in-the-v4-bot-framework-via-direct-line-and-liveperson/
I'm creating my first Microsoft Teams extension. For now I'm just trying to get the basic plumbing for a messaging extension working. I'm trying to build an extension which will allow a user to search for content in my service and then return a card into their compose window in personal and Teams chats.
I've tried to follow the basic guide ( https://learn.microsoft.com/en-us/microsoftteams/platform/messaging-extensions/how-to/create-messaging-extension ) for creating a messaging extension using App Studio. I've setup a bot as it describes, and I have built a dummy echobot endpoint for the bot (using Ruby). I am able to "chat" with my bot directly in the Teams client and it is able to respond.
My messaging extension defines an action based command with a taskInfo with a web view URL to render and a fetchTask set to false. I've written a basic static HTML page for this and included the teams-js library. The web view loads and the teams-js library initialization callback is called. I have a submit button which calls microsoftTeams.tasks.submitTask which as I understand it, should be calling my bot with a "composeExtension/submitAction" message to which I would respond with the card. (Based on https://learn.microsoft.com/en-us/microsoftteams/platform/messaging-extensions/how-to/action-commands/respond-to-task-module-submit?tabs=json )
I've tried installing my extension in Teams through the "Upload a custom app" option both as a "for me and my teams" and "for " but still have the following issues.
When I open my extension in the Teams client from the compose area and click this submit button in my iframe content, the submit I get a "Unable to reach app. Please try again" error displayed. In the dev console, I can see that the response to the "invoke" http post is {"errorCode":404,"message":"V3 agent not found."}
No traffic is actually sent to my bot during any of this process.
I saw this older post - Compose extension is throwing error : V3 agent not found . The https://dev.botframework.com/bots/ it refers to seems to be outdated, but in the Azure "Bot Channels Registration" console, I have gone to Channels and added "Microsoft Teams" (which I believe is the new equivalent).
Has anyone seen this happen and figured out what was going on? Much thanks!
Here is sample code for composeExtension/submitAction for Bot SDK V3. Make sure you pass the bot id and command text in taskInfo object.
case "composeExtension/submitAction":
string commandid = JsonConvert.DeserializeObject<Models.TaskModuleSubmitData<string>>(activityValue).commandId;
taskInfo = GetTaskInfo(commandid);
taskEnvelope = new Models.TaskEnvelope
{
Task = new Models.Task()
{
Type = Models.TaskType.Continue,
TaskInfo = taskInfo
}
};
return Request.CreateResponse(HttpStatusCode.OK, taskEnvelope);
Hilton had the right answer.
I had grabbed the Subscription ID from the Bot Channels Registration page instead of the App ID from the Azure Active Directory -> Apps Registration page and used that in the messaging extension manifest as the "botId" in the composeExtensions array. After fixing that I'm now getting messages submitted to my bot backend.
H, I'm working on a healthcare project which is using Microsoft Healthcare Bot as a tool. I followed the GitHub: https://github.com/Microsoft/HealthBotContainerSample/, and set it up successfully. right now what I can subscribe from the bot is activity property, using the below sample code:
botConnection.postActivity({type: "activity", value: jsonWebToken, from: user, name: "InitAuthenticatedConversation"}).subscribe(function (id) {
});
botConnection.activity$.filter(function(activity)
{
return activity.type === "activity"
})
.subscribe(function (activity)
{
console.log(activity);
});
and the first screenshot is what i get:
However, there is one thing I can't find any corresponding API, if I interact with bot on Azure, there is an Object with contains scenario stack, intent, score and so on (see the screenshot). But I can't find which API can help me retrieve this object,So, how to retrieve the object showing in the watch window?
Unfortunately, it does not look like there is a way in which a trace can be logged outside of the Scenario Designer for the HealthBot. I tested this and it looks like the trace is not emitted by the bot as any sort of event or message activity and only outputs from the bot, itself.
There are a couple avenues you can take, however.
One, if you sign up for Application Insights in Azure and include the Instrumentation Key, then you can log how the application (i.e. bot) is performing. This will capture any trace events emitted by the bot, however, the telemetry is not the same. It will allow you to see when they are occurring. The below screenshot from Azure shows an example.
To add in Application Insights, in your HealthBot in Azure, navigate to Integration => Secrets. You can then add the Instrumentation Key and save. It generally takes a few moments for activity to populate when viewing Application Insights, so be patient.
The second thing you can do is submit a Feature Request on their GitHub repo here requesting trace events be made available externally for logging and inspection.
Additionally, there is a Microsoft TechCommunity that you can participate in. I don't know if it is monitored for issues/requests, but it is worth trying.
Hope of help!
I have the following code:
import { ActivityTypes, CardFactory, TurnContext } from "botbuilder";
export class MyBot {
/**
* Handles incoming activity, received from a user, processes it, and replies as needed
* #param {TurnContext} context on turn context object.
*/
public onTurn = async (turnContext: TurnContext) => {
const oauthCard = CardFactory.oauthCard("ms-graph", "Login", "Please sign in so I know who you are");
return await turnContext.sendActivity({ attachments: [oauthCard] });
}
}
When I run the bot in bot emulator framework, I see the login button. When I click on it however, it just opens an empty signin window that's all white.
I've also configured authentication in Azure:
Edit: I've also configured the app id and password in my .bot file.
There is an option to use Azure Service Bus in place of ngrok which may work for you. It functions much the same but gives you control over where your data is traveling when "tunneling", among other benefits. As it's an Azure service, it can live in the same subscription you already access.
In short, you'll create a local client application that connects your bot via a relay to the Azure Service Bus service. The service bus namespace/relay replaces the messaging endpoint in the bot settings in Azure (for testing). In this way your bot running on localhost can connect to external services. Just be sure to use the same endpoint in Emulator that you use in the Azure bot settings, including the "/api/messages".
The instructions found here can guide you thru the process of setting up and running. The steps are a little long looking but the process itself is fairly simple. There are two options to build: a .NET Framework and a .NET Core. I would recommend the "Framework" version unless you need to run this on a Mac. This isn't an official MS blog (yet) but expect it to show up there.
Hope of help!
We have an assistant built using the bot framework (V3 SDK). It is connected to the Facebook channel.
Within the Facebook page setup, we have a group of testers configured.
One of our testers does not receive a response from the bot. Other testers do. We have removed the user from the test group, and have readded him (same as our other testers who are working fine), and still no responses.
The messages from the user show in the page's inbox.
Our logging shows that it never gets to the bot framework though.
Note, we have 10+ testers, and this is the only user that has this issue. All others, are able to send and receive messages as expected.
When I connect using ngrok, the messages are routed properly, and the conversation occurs as expected. I then disconnect ngrok, and the user is no longer able to have a conversation again.
The user was able to test for the previous 8 months, and this issue just started about two weeks ago.
I am at a loss for what it could be.