Skip to content

Commit

Permalink
[repo] fix: on default say action ensure command has response (#1230)
Browse files Browse the repository at this point in the history
## Linked issues

closes: #1186 

## Details

- on default say command ensure response is present
  • Loading branch information
aacebo authored Feb 1, 2024
1 parent 752b75e commit 87fd35c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ public async Task<string> DoCommandAsync([ActionTurnContext] ITurnContext turnCo
public async Task<string> SayCommandAsync([ActionTurnContext] ITurnContext turnContext, [ActionParameters] PredictedSayCommand command, CancellationToken cancellationToken = default)
{
Verify.ParamNotNull(command);
Verify.ParamNotNull(command.Response);

string response = command.Response;
if (turnContext.Activity.ChannelId == Channels.Msteams)
{
await turnContext.SendActivityAsync(response.Replace("\n", "<br>"), null, null, cancellationToken);
await turnContext.SendActivityAsync(command.Response.Replace("\n", "<br>"), null, null, cancellationToken);
}
else
{
await turnContext.SendActivityAsync(response, null, null, cancellationToken);
await turnContext.SendActivityAsync(command.Response, null, null, cancellationToken);
};

return string.Empty;
Expand Down
9 changes: 6 additions & 3 deletions js/packages/teams-ai/src/AI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,14 @@ export class AI<TState extends TurnState = TurnState> {

// Register default SayCommandActionName
this.defaultAction<PredictedSayCommand>(AI.SayCommandActionName, async (context, state, data, action) => {
const response = data.response;
if (!data.response) {
return '';
}

if (context.activity.channelId == Channels.Msteams) {
await context.sendActivity(response.split('\n').join('<br>'));
await context.sendActivity(data.response.split('\n').join('<br>'));
} else {
await context.sendActivity(response);
await context.sendActivity(data.response);
}

return '';
Expand Down

0 comments on commit 87fd35c

Please sign in to comment.