diff --git a/README.md b/README.md index bb1f393..d783e21 100644 --- a/README.md +++ b/README.md @@ -86,14 +86,26 @@ By selecting quick replies instead of typing manually, agents/users can respond - **`/quick`**: Get started with Quick Reply - **`/quick create`**: Create a new quick reply +- **`/quick create "" `**: Create a quick reply directly from the message box with a name and message - **`/quick list`**: List all your quick replies - **`/quick config`**: Configure your language preferences and AI settings - **`/quick ai`**: Use AI to generate replies - **`/quick help`**: Get help with Quick Reply - **`/qs `**: Quickly search and send a reply by name -### Using Placeholders: +#### Creating Quick Replies from Message Box +**`/quick create "" `**: "if your name has multiple words with space, use double quotes" and write everything else as a body! + +Example: `/quick create "schedule meeting" let's have a quick meet in an hour!` + +

or

+ +**`/quick create `**: You can write name without using double quotes if the name doesn't have spaces! + +Example: `/quick create greeting Hey there! Welcome to our channel 👋` + +### Using Placeholders: When creating or configuring a reply, you can use placeholders like `[name]`, `[username]`, and `[email]` in the reply content. These placeholders will automatically be replaced based on the recipient's information when the message is sent. diff --git a/src/commands/CommandUtility.ts b/src/commands/CommandUtility.ts index 3c07bdd..be582c2 100644 --- a/src/commands/CommandUtility.ts +++ b/src/commands/CommandUtility.ts @@ -65,8 +65,17 @@ export class CommandUtility implements ICommandUtility { triggerId: this.triggerId, threadId: this.threadId, language, + params: this.params, }); + 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(); diff --git a/src/definition/handlers/IHandler.ts b/src/definition/handlers/IHandler.ts index d589bf0..93ab321 100644 --- a/src/definition/handlers/IHandler.ts +++ b/src/definition/handlers/IHandler.ts @@ -10,4 +10,5 @@ export interface IHandler extends Omit { export type IHanderParams = Omit & { language: Language; + params?: string[]; }; diff --git a/src/handlers/Handler.ts b/src/handlers/Handler.ts index 5f4c0ca..d710edf 100644 --- a/src/handlers/Handler.ts +++ b/src/handlers/Handler.ts @@ -35,6 +35,7 @@ export class Handler implements IHandler { public triggerId?: string; public threadId?: string; public language: Language; + public params?: string[]; constructor(params: IHanderParams) { this.app = params.app; @@ -47,6 +48,8 @@ export class Handler implements IHandler { this.triggerId = params.triggerId; this.threadId = params.threadId; this.language = params.language; + this.params = params.params; + const persistenceRead = params.read.getPersistenceReader(); this.roomInteractionStorage = new RoomInteractionStorage( params.persis, @@ -56,6 +59,8 @@ export class Handler implements IHandler { } public async CreateReply(): Promise { + const initialReplyName = this.params?.[1]; + const initialReplyBody = this.params?.slice(2).join(' '); const modal = await CreateReplyModal( this.app, this.sender, @@ -64,13 +69,14 @@ export class Handler implements IHandler { this.modify, this.room, this.language, + initialReplyName, + initialReplyBody, ); if (modal instanceof Error) { this.app.getLogger().error(modal.message); return; } - const triggerId = this.triggerId; if (triggerId) { diff --git a/src/modal/common/inputElementComponent.ts b/src/modal/common/inputElementComponent.ts index b95937d..92cb0c0 100644 --- a/src/modal/common/inputElementComponent.ts +++ b/src/modal/common/inputElementComponent.ts @@ -50,6 +50,7 @@ export function inputElementComponent( text: label, element: plainTextInputElement, optional, + blockId, }); return plainTextInputBlock; diff --git a/src/modal/createModal.ts b/src/modal/createModal.ts index 7815e98..53f8546 100644 --- a/src/modal/createModal.ts +++ b/src/modal/createModal.ts @@ -25,7 +25,10 @@ export async function CreateReplyModal( modify: IModify, room: IRoom, language: Language, + initialReplyName?: string, + initialReplyBody?: string, ): Promise { + const { elementBuilder, blockBuilder } = app.getUtils(); const blocks: InputBlock[] = []; @@ -39,6 +42,7 @@ export async function CreateReplyModal( placeholder: placeholderReplyName, label: labelReplyName, optional: false, + initialValue: initialReplyName, }, { blockId: CreateModalEnum.REPLY_NAME_BLOCK_ID, @@ -56,6 +60,7 @@ export async function CreateReplyModal( label: labelReplyBody, optional: false, multiline: true, + initialValue: initialReplyBody, }, { blockId: CreateModalEnum.REPLY_BODY_BLOCK_ID, @@ -91,4 +96,4 @@ export async function CreateReplyModal( close, submit, }; -} +} \ No newline at end of file