-
Notifications
You must be signed in to change notification settings - Fork 554
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
Problem to list convo and send message #2775
Comments
I was having the same issue. the problem is that you need to use service proxy to forward the request to the chat service. To do this, you need to add the following header: "Atproto-Proxy": "did:web:api.bsky.chat#bsky_chat", However, in order to use the service proxy, you cannot send the request to the PDS Entryway service (i.e. Here is my implementation: import axios from "axios";
const SOCIAL_BASE_URL = "https://bsky.social/xrpc";
export const blueSkySocialAPI = axios.create({ baseURL: SOCIAL_BASE_URL });
export type Session = {
did: string;
accessJwt: string;
refreshJwt: string;
service: {
id: string;
type: string;
serviceEndpoint: string;
}[];
};
export const createSession = async (): Promise<Session> => {
const { data } = await blueSkySocialAPI.post(
"com.atproto.server.createSession",
{
identifier: process.env.BLUESKY_USERNAME,
password: process.env.BLUESKY_APP_PASSWORD,
},
{
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
},
);
blueSkySocialAPI.defaults.headers.common["Authorization"] =
`Bearer ${data.accessJwt}`;
return {
did: data.did,
accessJwt: data.accessJwt,
refreshJwt: data.refreshJwt,
service: data.didDoc.service,
};
};
export const listConvos = async (accountPDS: string) => {
const url = "chat.bsky.convo.listConvos";
const resp = await blueSkySocialAPI.get(url, {
headers: {
"Content-Type": "application/json",
Accept: "application/json",
"Atproto-Proxy": "did:web:api.bsky.chat#bsky_chat",
},
baseURL: `${accountPDS}/xrpc`,
});
return resp.data;
};
const session = await createSession();
const convos = await listConvos(session.service[0].serviceEndpoint);
console.log(convos); I'm not sure if this is the most straightforward way, but it works. |
I'm sorry but my implementation was wrong |
@Cristuker how was your implementation wrong? I am running into a similar issue. |
@Lermatroid I don't remember exactly what I refactored, but this is the link to the file. I did many refactors after this post but if you search into the commits it can help you https://github.com/Cristuker/save-to-later/blob/main/src/sendMessage.ts |
Describe the bug
Well Im trying to create a bot who send message on DM to save posts. I tried using HTTP request like the below code and I receive 404 always following the doc and also I tried using the package for typescript but I received this error XRPCError: XRPC Not Supported #1954
but this solution don't work for me.
To Reproduce
Steps to reproduce the behavior:
the other approach
Expected behavior
list convos for the did that I send
Details
The text was updated successfully, but these errors were encountered: