Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/q slack chat stream #57

Open
wants to merge 3 commits into
base: feature/q-slack-chat-stream
Choose a base branch
from

Conversation

leenmin-aws
Copy link
Collaborator

@leenmin-aws leenmin-aws commented Aug 30, 2024

Description of changes:

Dylan-Dipasupil#2

To support Q-Slack-Gateway Chat API streaming feature there will be an additional lambda handler function. The callback url will be an output of the CloudFormation template -> Slack admin can change the slack app's Event Subscription Request url to either the ChatSync event handler or the Chat event handler.

These are prereq commits to helper/utility functions to function with both ChatSync & Chat API.

Manual testing on slack client to see if functionality remained the same -> additional unit tests will be added & existing ones modified if needed in future commits.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Update package.json

Update aws packages to v3.620.0
Fix event streaming bug with ChatAPI.
Bugfix here: https://github.com/aws/aws-sdk-js-v3/releases/tag/v3.620.0
Prereq for Chat API feature.

Update IAM permissions for Chat API

Add Chat to IAM role.
Prereq for Chat API streaming feature.

Add slack-stream-event lambda handler

To allow the optional streaming feature of ChatAPI we add an additional lambda handler.

Admin can choose between which endpoint will handle slack events.

Modify helper functions to fit both ChatSync & Chat

Keep code DRY by not remaking each helper function.

1. Add "commandType" to chat & callClient to determine return type.
2. Modify getResponseAsBlocks inputs to fit Chat API outputstream.
3. Add optional MetadataEvent typing to saveMessageMetadata & getFeedbackBlocks for ChatAPI.

Remove `chat` function and directly use client calls

1. Remove chat function to avoid double conditionals
2. Add the sendChatSyncCommand & sendChatCommand functions to dependencies.

Add updated unit tests for ChatSync & Chat

1. Add mock responses for Chat API
2. Modify mocks to have two separate calls for ChatSync/Chat.
3. Modify unit tests to fit (2).
4. Create new unit test file for slack-stream-event-handler.ts.
All the tests are the same as slack-event-handler.test.ts except for the 5 that start with "Should chat" -> Modified to fit Chat API output.

refactor: remove 'any' type from input object in sendChatSyncCommand

Update slack event handler to use modified helpers

Create slack-stream-event-handler

1. Optional event subscription endpoint for slack.
2. Code is identical to slack-event-handler.ts until line 334.

Update READMEs with chat stream feature setup

Remove unnecessary variable `latestTextEvent`

Previous implementations required the latestTextEvent for future references after loop -> this is no longer required.

Update CHANGELOG date

Modify `sendChatSyncCommand` and `sendChatCommand` to be thin wrappers

1. Moved the try catch & truncating to amazon-q-helpers.ts & dumbed logic down in amazon-q-client.ts functions to only be thing wrappers.

Modify functions to fit `callChatSyncCommand` & `callChatCommand`
Add Lambda Handler for Slack-Gateway streaming & update helper functions for Chat API.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants