Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ By selecting quick replies instead of typing manually, agents/users can respond
- **`/quick ai`**: Use AI to generate replies
- **`/quick help`**: Get help with Quick Reply
- **`/qs <reply name>`**: Quickly search and send a reply by name
- **`/quick create <name> <message>`**: Create a quick reply directly from the input box with a name and message
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add screen shot how it look

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot from 2025-02-23 02-29-31

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put create command together , explain how double quotes works to name a reply

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double quotes ("") ? Explain double quote behavior here


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add SS

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add SS man why you are not making requested changes before asking for review.

#### Example:
```sh
/quick create greeting Hello! How have you been?
```
This will create a quick reply named **`greeting`**, which can be used later by typing **`/qs greeting`**

### Using Placeholders:

Expand Down
11 changes: 10 additions & 1 deletion src/commands/CommandUtility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,17 @@ export class CommandUtility implements ICommandUtility {
triggerId: this.triggerId,
threadId: this.threadId,
language,
args: this.params,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so basically the handler needs args to be passed to get the name and body from the cli so thats why i added params here to pass it down to handler function

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not name it params only then ?

});

if(this.params.length && this.params.length > 1){
const subCommand = this.params[0].toLowerCase();
if(subCommand === CommandParam.CREATE){
await this.handleSingleParam(handler)
return;
}
}

switch (this.params.length) {
case 0: {
await handler.sendDefault();
Expand All @@ -76,7 +85,7 @@ export class CommandUtility implements ICommandUtility {
await this.handleSingleParam(handler);
break;
}
default: {
default: {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

await handler.sendDefault();
}
}
Expand Down
1 change: 1 addition & 0 deletions src/definition/handlers/IHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ export interface IHandler extends Omit<ICommandUtilityParams, 'params'> {

export type IHanderParams = Omit<ICommandUtilityParams, 'params'> & {
language: Language;
args? : string[];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why optional ? it will always be there

};
14 changes: 6 additions & 8 deletions src/handlers/ExecuteViewSubmitHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,12 @@ export class ExecuteViewSubmitHandler {
language: Language,
triggerId: string,
): Promise<IUIKitResponse> {
const nameStateValue =
view.state?.[CreateModalEnum.REPLY_NAME_BLOCK_ID]?.[
CreateModalEnum.REPLY_NAME_ACTION_ID
];
const bodyStateValue =
view.state?.[CreateModalEnum.REPLY_BODY_BLOCK_ID]?.[
CreateModalEnum.REPLY_BODY_ACTION_ID
];
const nameStateValue = view.state && Object.values(view.state)
Copy link
Contributor Author

@not-meet not-meet Feb 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so the reason to add this new logic of fetching the states of name and body is because when you try to create a reply from the prefilled values the view state don't have the block id

Screenshot from 2025-02-23 02-22-10

where as the name and body provided from the modal have the block id thus to take the values of action id which is the only thing we need in both cases i added find logic which works well in both the cases as it only takes out the reply action id

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code is so bad adding find don't make sense to me here and again you are not using enums , please find why enum are good and how we are using in this case.

.find(obj => 'reply-name-action-id' in obj)
?.['reply-name-action-id'];
const bodyStateValue = view.state && Object.values(view.state)
.find(obj => 'reply-body-action-id' in obj)
?.['reply-body-action-id'];

const name = nameStateValue ? nameStateValue.trim() : '';
const body = bodyStateValue ? bodyStateValue.trim() : '';
Expand Down
9 changes: 8 additions & 1 deletion src/handlers/Handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class Handler implements IHandler {
public triggerId?: string;
public threadId?: string;
public language: Language;
public args? : string[];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same


constructor(params: IHanderParams) {
this.app = params.app;
Expand All @@ -47,6 +48,8 @@ export class Handler implements IHandler {
this.triggerId = params.triggerId;
this.threadId = params.threadId;
this.language = params.language;
this.args = params.args;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?


const persistenceRead = params.read.getPersistenceReader();
this.roomInteractionStorage = new RoomInteractionStorage(
params.persis,
Expand All @@ -56,6 +59,8 @@ export class Handler implements IHandler {
}

public async CreateReply(): Promise<void> {
const cliName = this.args?.[1] || '';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we give them better naems like initial name or something ? or can we just make one object that have both values

const cliBody = this.args?.slice(2).join(' ') || '';
const modal = await CreateReplyModal(
this.app,
this.sender,
Expand All @@ -64,13 +69,15 @@ export class Handler implements IHandler {
this.modify,
this.room,
this.language,
cliName,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather than passing the args to the create modal i have passed cliname and clibody to the modal for the initial values

cliBody,
);

if (modal instanceof Error) {
this.app.getLogger().error(modal.message);
return;
}

const triggerId = this.triggerId;

if (triggerId) {
Expand Down
7 changes: 6 additions & 1 deletion src/modal/createModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ export async function CreateReplyModal(
modify: IModify,
room: IRoom,
language: Language,
cliName: string,
cliBody: string,
): Promise<IUIKitSurfaceViewParam | Error> {

const { elementBuilder, blockBuilder } = app.getUtils();

const blocks: InputBlock[] = [];
Expand All @@ -39,6 +42,7 @@ export async function CreateReplyModal(
placeholder: placeholderReplyName,
label: labelReplyName,
optional: false,
initialValue: cliName,
},
{
blockId: CreateModalEnum.REPLY_NAME_BLOCK_ID,
Expand All @@ -56,6 +60,7 @@ export async function CreateReplyModal(
label: labelReplyBody,
optional: false,
multiline: true,
initialValue: cliBody,
},
{
blockId: CreateModalEnum.REPLY_BODY_BLOCK_ID,
Expand Down Expand Up @@ -91,4 +96,4 @@ export async function CreateReplyModal(
close,
submit,
};
}
}