Tools in Teams AI Library

Copper Contributor

Hello Team,

In LLM we use tools like DynamicTool, DynamicStructuredTool to determine when to call which function and with what parameters. How to do the same using Teams AI Library?

My Use Case:
I want to find the intent from the user query and based on that intent further call the respective function/tool to perform respective action. How can I achieve this using Teams AI Library?
I went through the samples mentioned here:
but couldn't find anything similar.

10 Replies

@Janhvi ,
Thanks for posting you query here. We will look into it and let you know.

Following the below example, I have replicated tools using actions :
Now if I want to create hierarchy of this action i.e under one action I want to create a set of other actions. How can we do that?

Use Case: Once it has understood the intent to execute the following action, now I want sub actions to be performed for that particular intent.
For example : Intents are creation, modification, deletion etc
Now when it understood the intent as modification, I further want this action to have sub actions say
1) Time (when was it modified)
2) User Event (who modified it)
3) Modified since (what are the modifications since yesterday) and so on
And these sub actions based on the data source provided so how to add data source as well.
How to achieve this?

Hello @Janhvi,
Can you please try to register subhandlers for actions using the Teams AI Library.


import { Application, ApplicationTurnState, PauseParameters } from 'your-teams-ai-library'; // Import necessary types from the Teams AI Library

// Define the JSON data for actions and subactions
const actionsAndSubactions = [
"name": "Pause",
"description": "Delays for a period of time",
"subactions": [
"name": "Resume",
"description": "Resumes after pause"
"name": "Stop",
"description": "Stops the pause"
// Add more actions and subactions as needed

// Define the subaction handlers

const subactionHandlers: { [name: string]: (context: any, state: ApplicationTurnState, parameters: any) => Promise<string> } = {
async Resume(context: any, state: ApplicationTurnState, parameters: any) {
// Implement logic for handling the Resume subaction
return "Resume logic executed";
async Stop(context: any, state: ApplicationTurnState, parameters: any) {
// Implement logic for handling the Stop subaction
return "Stop logic executed";
// Add more subaction handlers as needed

// Initialize the application
const app = new Application<ApplicationTurnState>({
ai: {

// Register action handlers
actionsAndSubactions.forEach(action => {, async (context: any, state: ApplicationTurnState, parameters: PauseParameters) => {

const subactionName = context.activity.value?.subaction;

if (subactionName && subactionHandlers[subactionName]) {
return subactionHandlers[subactionName](context, state, parameters);
} else {
await context.sendActivity(`[pausing for ${parameters.time / 1000} seconds]`);
await new Promise((resolve) => setTimeout(resolve, parameters.time));
return `done pausing`;



Thank you so much @Vaibhav-MSFT !

Apart from the below two links, where do I find references or document for all of this?

Are there any more documentation links?
Also if I want the actions to be performed on some data that I provide, how to achieve that?

Hello @Vaibhav-MSFT

The code line
const subactionName = context.activity.value?.subaction;
that you mentioned in the above code, doesn't work as context.activity.value is undefined
I checked it with the latest version as well.

Also where will I find the above reference code?

Hi @Janhvi,
The context.activity.value "undefined" indicates that activity received by the bot does not contain a value property.
Can you add a check before for handling this-
// Check if context.activity.value exists and has a subaction property

if (context.activity.value && context.activity.value.subaction)
subactionName = context.

Hello @Vaibhav-MSFT
context.activity.value does not exist.
Hence it will never be able to perform the function provided for any subaction

@Janhvi ,
We are in conversation with engineering team and will update you once we get more information on this.

Sure, Thank you!
Also meanwhile can you please provide link for resources for Team AI library apart from the below two links:

Hello @Janhvi ,
As of for now these are the only official documentation related to Teams AI library but we constantly sync with engineering team to add more information.
We will update you once we get any response.