-
Notifications
You must be signed in to change notification settings - Fork 175
Add follow-up question support to Teams request action #2398
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
Merged
ravikiranvm
merged 3 commits into
main
from
add-follow-up-question-to-teams-request-action
Jul 15, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
packages/blocks/microsoft-teams/src/lib/common/build-wrapper-url.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| const RESUME_PAGE = 'resume_execution.html'; | ||
| const COLLECT_INPUT_PAGE = 'collect_input.html'; | ||
|
|
||
| const ANSWER_FORMATS = new Set(['text', 'email', 'number']); | ||
| const DEFAULT_ANSWER_FORMAT = 'text'; | ||
|
|
||
| export type ButtonFollowUp = { | ||
| question: string; | ||
| answerFormat?: string; | ||
| noAnswerOption?: string; | ||
| title?: string; | ||
| }; | ||
|
|
||
| // The collect-input page sends the answer back as the `answer` resume query | ||
| // param, surfaced in the step output as parameters.answer. | ||
| export function buildWrapperUrl({ | ||
| frontendUrl, | ||
| isTest, | ||
| resumeUrl, | ||
| followUp, | ||
| }: { | ||
| frontendUrl: string; | ||
| isTest: boolean; | ||
| resumeUrl: string; | ||
| followUp?: ButtonFollowUp; | ||
| }): string { | ||
| const question = followUp?.question?.trim(); | ||
|
|
||
| if (!question) { | ||
| return `${frontendUrl}/html/${RESUME_PAGE}?isTest=${isTest}&redirectUrl=${encodeURIComponent( | ||
| resumeUrl, | ||
| )}`; | ||
| } | ||
|
|
||
| const format = | ||
| followUp?.answerFormat && ANSWER_FORMATS.has(followUp.answerFormat) | ||
| ? followUp.answerFormat | ||
| : DEFAULT_ANSWER_FORMAT; | ||
|
|
||
| const params = new URLSearchParams({ | ||
| isTest: String(isTest), | ||
| question, | ||
| format, | ||
| redirectUrl: resumeUrl, | ||
| }); | ||
|
|
||
| const noAnswerOption = followUp?.noAnswerOption?.trim(); | ||
| if (noAnswerOption) { | ||
| params.set('noAnswerOption', noAnswerOption); | ||
| } | ||
|
|
||
| const title = followUp?.title?.trim(); | ||
| if (title) { | ||
| params.set('title', title); | ||
| } | ||
|
|
||
| return `${frontendUrl}/html/${COLLECT_INPUT_PAGE}?${params.toString()}`; | ||
| } |
3 changes: 3 additions & 0 deletions
3
packages/blocks/microsoft-teams/src/lib/common/generate-message-with-buttons.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
packages/blocks/microsoft-teams/test/build-wrapper-url.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| import { buildWrapperUrl } from '../src/lib/common/build-wrapper-url'; | ||
|
|
||
| const baseParams = { | ||
| frontendUrl: 'https://app.openops.com', | ||
| isTest: false, | ||
| resumeUrl: | ||
| 'https://api.openops.com/v1/flow-runs/run-1/requests/pause-1?button=Not%20mine&path=step_1', | ||
| }; | ||
|
|
||
| const encodedResumeUrl = encodeURIComponent(baseParams.resumeUrl); | ||
|
|
||
| describe('buildWrapperUrl', () => { | ||
| test('uses the default resume page when no follow-up question is given', () => { | ||
| const url = buildWrapperUrl(baseParams); | ||
|
|
||
| expect(url).toBe( | ||
| `https://app.openops.com/html/resume_execution.html?isTest=false&redirectUrl=${encodedResumeUrl}`, | ||
| ); | ||
| }); | ||
|
|
||
| test('uses the collect-input page when a follow-up question is given', () => { | ||
| const url = buildWrapperUrl({ | ||
| ...baseParams, | ||
| followUp: { | ||
| question: "What is the correct owner's email?", | ||
| answerFormat: 'email', | ||
| }, | ||
| }); | ||
|
|
||
| const parsed = new URL(url); | ||
| expect(parsed.origin).toBe('https://app.openops.com'); | ||
| expect(parsed.pathname).toBe('/html/collect_input.html'); | ||
| expect(parsed.searchParams.get('question')).toBe( | ||
| "What is the correct owner's email?", | ||
| ); | ||
| expect(parsed.searchParams.get('format')).toBe('email'); | ||
| expect(parsed.searchParams.get('isTest')).toBe('false'); | ||
| expect(parsed.searchParams.get('redirectUrl')).toBe(baseParams.resumeUrl); | ||
| }); | ||
|
|
||
| test('includes the message header as the form title when given', () => { | ||
| const url = buildWrapperUrl({ | ||
| ...baseParams, | ||
| followUp: { | ||
| question: 'Who owns this?', | ||
| title: 'Cost savings opportunity: vol-123', | ||
| }, | ||
| }); | ||
|
|
||
| expect(new URL(url).searchParams.get('title')).toBe( | ||
| 'Cost savings opportunity: vol-123', | ||
| ); | ||
| }); | ||
|
|
||
| test('includes the no-answer option when given', () => { | ||
| const url = buildWrapperUrl({ | ||
| ...baseParams, | ||
| followUp: { | ||
| question: "What is the correct owner's email?", | ||
| noAnswerOption: "I don't know the owner", | ||
| }, | ||
| }); | ||
|
|
||
| expect(new URL(url).searchParams.get('noAnswerOption')).toBe( | ||
| "I don't know the owner", | ||
| ); | ||
| }); | ||
|
|
||
| test('omits the no-answer option param when not given', () => { | ||
| const url = buildWrapperUrl({ | ||
| ...baseParams, | ||
| followUp: { question: 'Why was this dismissed?' }, | ||
| }); | ||
|
|
||
| expect(new URL(url).searchParams.has('noAnswerOption')).toBe(false); | ||
| }); | ||
|
|
||
| test('ignores a follow-up with an empty question', () => { | ||
| const url = buildWrapperUrl({ | ||
| ...baseParams, | ||
| followUp: { question: ' ' }, | ||
| }); | ||
|
|
||
| expect(url).toContain('/html/resume_execution.html?'); | ||
| }); | ||
|
|
||
| test('defaults the answer format to text for unknown formats', () => { | ||
| const url = buildWrapperUrl({ | ||
| ...baseParams, | ||
| followUp: { question: 'Why?', answerFormat: 'dropdown' }, | ||
| }); | ||
|
|
||
| expect(new URL(url).searchParams.get('format')).toBe('text'); | ||
| }); | ||
|
|
||
| test('passes isTest through', () => { | ||
| const url = buildWrapperUrl({ ...baseParams, isTest: true }); | ||
|
|
||
| expect(url).toContain('isTest=true'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.