@microsoft/agents-hosting-express package
Functions
| start |
Starts an Express server for handling Agent requests. Example
|
Function Details
startServer(AgentApplication<TurnState<any, any, DefaultTempState>> | ActivityHandler, AuthConfiguration)
Starts an Express server for handling Agent requests.
Example
import { AgentApplication, TurnState } from '@microsoft/agents-hosting';
import { startServer } from '@microsoft/agents-hosting-express';
const app = new AgentApplication<TurnState>();
app.onMessage('hello', async (context, state) => {
await context.sendActivity('Hello, world!');
});
startServer(app);
function startServer(agent: AgentApplication<TurnState<any, any, DefaultTempState>> | ActivityHandler, authConfiguration?: AuthConfiguration): Express
Parameters
- agent
-
AgentApplication<TurnState<any, any, DefaultTempState>> | ActivityHandler
The AgentApplication or ActivityHandler instance to process incoming activities.
- authConfiguration
- AuthConfiguration
Optional custom authentication configuration. If not provided, configuration will be loaded from environment variables using loadAuthConfigFromEnv().
Returns
Express
void - This function does not return a value as it starts a long-running server process.
Remarks
This function sets up an Express server with the necessary middleware and routes for handling agent requests. It configures JWT authorization middleware and sets up the message endpoint. The server will listen on the port specified in the PORT environment variable (or 3978 by default) and logs startup information including the SDK version and configured app ID.