Skip to content

Comments

feat: exposes method for updating connection messages and get contact information#76

Open
vieiraricardo wants to merge 1 commit intoreleases/v1.1.0from
feat/expose-update-connection-message
Open

feat: exposes method for updating connection messages and get contact information#76
vieiraricardo wants to merge 1 commit intoreleases/v1.1.0from
feat/expose-update-connection-message

Conversation

@vieiraricardo
Copy link
Collaborator

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request enhances the SuperDapp Agents SDK by adding message update capabilities and contact retrieval functionality. The changes enable agents to update previously sent messages and fetch contact information by Cognito ID, while also improving the internal routing logic for channel messages.

Changes:

  • Added PUT HTTP method support to the client's fetch implementation
  • Implemented getContactByCognitoId() method for retrieving contact information via internal API route
  • Updated updateConnectionMessage() to use SendMessageOptions parameter type and added fetch API support (previously only supported axios)
  • Added updateConnectionMessage() wrapper method to SuperDappAgent for easier message updates
  • Enhanced sendReplyMarkupMessage() to properly route channel messages through the channel endpoint

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
src/core/client.ts Added PUT method support, implemented getContactByCognitoId method, updated updateConnectionMessage to use SendMessageOptions with dual fetch/axios support
src/core/agent.ts Added updateConnectionMessage wrapper method and improved sendReplyMarkupMessage to route channel messages correctly

Comment on lines 344 to 348
async updateConnectionMessage(
connectionId: string,
messageId: string,
message: string | { body: string }
options: SendMessageOptions
): Promise<ApiResponse> {
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JSDoc comment on line 342 states "Accepts a string or an object with { body }" but the parameter type has been changed to SendMessageOptions, which is more restrictive. The comment should be updated to accurately reflect that this method now expects a SendMessageOptions object containing a message property with a MessageBody structure and an optional isSilent boolean.

Copilot uses AI. Check for mistakes.
Comment on lines 344 to 363
async updateConnectionMessage(
connectionId: string,
messageId: string,
message: string | { body: string }
options: SendMessageOptions
): Promise<ApiResponse> {
const payload = { message };
if (this.useFetch) {
return this.fetchJson(
'PUT',
`${AGENT_BOTS_CONNECTIONS_ENDPOINT}/${encodeURIComponent(connectionId)}/messages/${encodeURIComponent(messageId)}`,
options
);
}
const response = await this.axios.put(
`${AGENT_BOTS_CONNECTIONS_ENDPOINT}/${encodeURIComponent(
connectionId
)}/messages/${encodeURIComponent(messageId)}`,
payload
options
);
return response.data;
}
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This creates an API design inconsistency: updateConnectionMessage now uses SendMessageOptions with a structured format (message body + isSilent), while updateChannelMessage (line 382-395) still uses the simpler string | { body: string } signature. For consistency and maintainability, these two methods should follow the same pattern. Consider updating updateChannelMessage to also use SendMessageOptions and add fetch support similar to this implementation.

Copilot uses AI. Check for mistakes.
}

/**
* update connection message (DM)
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment should start with a capital letter and end with a period for consistency with other JSDoc comments in this file. It should be: "Update connection message (DM)"

Suggested change
* update connection message (DM)
* Update connection message (DM).

Copilot uses AI. Check for mistakes.
/**
* update connection message (DM)
*/

Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an extra blank line (line 109) between the JSDoc comment and the method declaration. This inconsistency should be removed to match the pattern used elsewhere in the file where JSDoc comments are immediately followed by the method declaration without blank lines.

Suggested change

Copilot uses AI. Check for mistakes.
Comment on lines +319 to +329
/**
* Get contact by cognito id (agent-bots internal route)
*/
async getContactByCognitoId(cognitoId: string): Promise<ApiResponse> {
const path = `${AGENT_BOTS_ENDPOINT}contacts/by-cognito/${encodeURIComponent(cognitoId)}`;
if (this.useFetch) {
return this.fetchJson('GET', path);
}
const response = await this.axios.get(path);
return response.data;
}
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new getContactByCognitoId method lacks test coverage. While other client methods in the test suite (like getMe, sendChannelMessage) have existence checks, this new method should have a test case verifying its existence and behavior, consistent with the testing pattern used for other API methods in src/tests/client.test.ts.

Copilot uses AI. Check for mistakes.
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.

1 participant