Skip to content

Commit d5bf838

Browse files
Merge pull request #2 from Dylan-Dipasupil/feature/q-slack-chat-stream
Add Lambda Handler for Slack-Gateway streaming & update helper functions for Chat API.
2 parents f489d3d + 9e504d9 commit d5bf838

16 files changed

+10576
-2309
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [0.3.0] - 2024-08-29
10+
### Added
11+
Add optional streaming response feature.
12+
- New Lambda function queries the Amazon Q Business Chat API and updates the Slack channel in real-time as LLM generates response.
13+
- Can easily switch between ChatSync and Chat response modes by modifying the Slack app's event subscription endpoint.
14+
915
## [0.2.0] - 2024-05-28
1016
### Added
1117
Add support for Q Business Apps integrated with IdC

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,19 @@ Let's now add your app into your workspace, this is required to generate the `Bo
161161
4. Choose `Edit`
162162
5. Replace the value of `OidcClientSecret`, you will find the value in the Okta app client settings (step 1.1).
163163

164+
#### 4.4 (Optional) Configure Slack app to use chat stream feature
165+
166+
To enable the streaming response feature, we need to modify the Slack app.
167+
168+
1. Login to your AWS console
169+
2. In your AWS account go to Cloudformation
170+
3. Copy the URL of the stack output ending with name : `SlackStreamEventHandlerApiEndpoint`.
171+
4. Open the Slack app settings (api.slack.com) and go to the Event Subscriptions section.
172+
5. In the Request URL block, select "change" and paste the copied URL into the "New Request URL" field.
173+
6. Save the changes.
174+
175+
To revert to using the ChatSync feature, follow the same steps, but in step 3, copy the stack output with the name `SlackEventHandlerApiEndpoint` instead.
176+
164177
### Say hello
165178
> Time to say Hi!
166179

README_DEVELOPERS.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,19 @@ Let's now add your app into your workspace, this is required to generate the `Bo
132132
4. Choose `Edit`
133133
5. Replace the value of `OidcClientSecret`, you will find those values in the IdP app client configuration.
134134

135+
#### 4.4 (Optional) Configure Slack app to use chat stream feature
136+
137+
To enable the streaming response feature, we need to modify the Slack app.
138+
139+
1. Login to your AWS console
140+
2. In your AWS account go to Cloudformation
141+
3. Copy the URL of the stack output ending with name : `SlackStreamEventHandlerApiEndpoint`.
142+
4. Open the Slack app settings (api.slack.com) and go to the Event Subscriptions section.
143+
5. In the Request URL block, select "change" and paste the copied URL into the "New Request URL" field.
144+
6. Save the changes.
145+
146+
To revert to using the ChatSync feature, follow the same steps, but in step 3, copy the stack output with the name `SlackEventHandlerApiEndpoint` instead.
147+
135148
### Say hello
136149
> Time to say Hi!
137150

lib/my-amazon-q-slack-bot-stack.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ export class MyAmazonQSlackBotStack extends cdk.Stack {
208208
ChatPolicy: new PolicyDocument({
209209
statements: [
210210
new PolicyStatement({
211-
actions: ['qbusiness:ChatSync', 'qbusiness:PutFeedback'],
211+
actions: ['qbusiness:ChatSync', 'qbusiness:Chat', 'qbusiness:PutFeedback'],
212212
// parametrized
213213
resources: [`arn:aws:qbusiness:*:*:application/${env.AmazonQAppId}`]
214214
})
@@ -249,7 +249,7 @@ export class MyAmazonQSlackBotStack extends cdk.Stack {
249249
ChatPolicy: new PolicyDocument({
250250
statements: [
251251
new PolicyStatement({
252-
actions: ['qbusiness:ChatSync', 'qbusiness:PutFeedback'],
252+
actions: ['qbusiness:ChatSync', 'qbusiness:Chat', 'qbusiness:PutFeedback'],
253253
resources: ['arn:aws:qbusiness:*:*:application/*']
254254
})
255255
]
@@ -316,6 +316,11 @@ export class MyAmazonQSlackBotStack extends cdk.Stack {
316316
handler: 'slack-command-handler',
317317
id: 'SlackCommandHandler',
318318
description: 'Handler for Slack commands'
319+
},
320+
{
321+
handler: 'slack-stream-event-handler',
322+
id: 'SlackStreamEventHandler',
323+
description: 'Handler for Slack events - Streams response'
319324
}
320325
].map((p) => {
321326
const prefix = `${props.stackName}-${p.id}`;

0 commit comments

Comments
 (0)