Skip to content

Commit

Permalink
Add metadata to incoming webhooks parameters (#1617)
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch committed May 1, 2023
1 parent a41c71e commit 0ba6dc2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/webhook/src/IncomingWebhook.spec.js
Expand Up @@ -47,6 +47,21 @@ describe('IncomingWebhook', function () {
this.scope.done();
});
});

it('should send metadata', function () {
const result = this.webhook.send({
text: 'Hello',
response_type: 'in_channel',
metadata: {
event_type: 'foo',
event_payload: { foo: 'bar'},
}
});
return result.then((result) => {
assert.strictEqual(result.text, 'ok');
this.scope.done();
});
});
});

describe('when the call fails', function () {
Expand Down
6 changes: 6 additions & 0 deletions packages/webhook/src/IncomingWebhook.ts
Expand Up @@ -68,6 +68,7 @@ export class IncomingWebhook {
try {
const response = await this.axios.post(this.url, payload);
return this.buildResult(response);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
// Wrap errors in this packages own error types (abstract the implementation details' types)
if (error.response !== undefined) {
Expand Down Expand Up @@ -111,6 +112,11 @@ export interface IncomingWebhookSendArguments extends IncomingWebhookDefaultArgu
blocks?: (KnownBlock | Block)[];
unfurl_links?: boolean;
unfurl_media?: boolean;
metadata?: {
event_type: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
event_payload: Record<string, any>;
};
}

export interface IncomingWebhookResult {
Expand Down

0 comments on commit 0ba6dc2

Please sign in to comment.