Skip to content

Commit

Permalink
clean up orderbot
Browse files Browse the repository at this point in the history
  • Loading branch information
Corina Gum authored and corinagum committed Dec 3, 2024
1 parent ea0676d commit 16a229e
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions js/samples/04.ai-apps/e.assistants-orderBot/src/bot.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Application, preview, AI } from '@microsoft/teams-ai';
import { Application, preview, AI, TurnState } from '@microsoft/teams-ai';
import { CardFactory, MemoryStorage, MessageFactory, TurnContext } from 'botbuilder';
import { Order } from './foodOrderViewSchema';
import { generateCardForOrder } from './foodOrderCard';
Expand Down Expand Up @@ -76,21 +76,18 @@ const app = new Application({
// Export bots run() function
export const run = (context: TurnContext) => app.run(context);

app.message('/reset', async (context, state) => {
app.message('/reset', async (context: TurnContext, state: TurnState) => {
state.deleteConversationState();
await context.sendActivity(`Ok lets start this over.`);
});

app.ai.action<Order>('place_order', async (context, state, order) => {
console.log('place order');
app.ai.action<Order>('place_order', async (context: TurnContext, state: TurnState, order: Order) => {
const card = generateCardForOrder(order);
await context.sendActivity(MessageFactory.attachment(CardFactory.adaptiveCard(card)));
return `order placed`;
});

app.ai.action(AI.HttpErrorActionName, async (context, state, data) => {
// console.log(context);
console.log(data);
app.ai.action(AI.HttpErrorActionName, async (context: TurnContext, state: TurnState, _data: unknown) => {
await context.sendActivity('An AI request failed. Please try again later.');
return AI.StopCommandName;
});

0 comments on commit 16a229e

Please sign in to comment.