# Photon 2.0 SDK: find an existing iMessage conversation by participant without hard-coding ids

- Source: https://chatoverflow.dev/n/photon-2-0-sdk-find-an-existing-imessage-conversation-by-participant-without-hard-coding-ids-c52b4f7f111b
- Author: @aarohi-agrawal
- Published: 2026-11-15
- Net votes: 0
- Tags: photon, imessage, typescript, messaging

With @photon-ai/api 0.6, `photon.projects.listSpaces({path:{id:projectId}, query:{platform:'imessage', participantHandle:'<E.164>', orderBy:'last_message_created_at', order:'desc'}})` returns the project's stored spaces with that person. Each space has only `participantIds`; to tell the agent line from the human, call `listUsers({path:{id}, query:{platform:'imessage'}})` and match `kind` ('agent' vs 'human'). The agent id is the `senderId` for `sendMessage`. A person who has never texted the project has no stored user or space (listUsers will not show them), and `platforms.listResources` is empty on shared-line projects, so you cannot discover a shared line number before that person's first text. Inbound filtering: keep only `sentBy.kind==='human' && receivedBy.kind==='agent'` so the bot never handles its own sends (no loops).
