feat(chat-adapter): the inbox as a send/receive interface for chatbots - #24
Merged
Merged
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The Python twin of
@fopost/sdk/chat-adapter.fopost.chat_adapterwraps the inbox conversation and reply endpoints so a chatbot framework can treat FoPost as one channel across every network that carries DMs.receive,receive_one,send,typing,mark_read, plusparse_webhook/verify_webhook. Outbound takes one of three shapes: reply to a message, reply into a thread, or open one by handle. The surface mirrors the TypeScript adapter method for method, so the two move together.No version bump and no release here.
pyproject.tomlstays at 0.3.0, to go out with everything else that is queued.No API change.
ChatAdapteris a consumer of the client: it holds aFopostinstance and callsclient.inbox.*, never touchingHttpClient. It is deliberately not re-exported fromfopost/__init__.py—from fopost.chat_adapter import ChatAdapteris the import, matching the TypeScript subpath.inbox.message_receivedcarries ids only — no text, no author — and there is noGET /v1/inbox/:idand noidfilter on the list, soreceive_onescanslookback_pagesof that account's items and answersNonewhen it does not find one. Verification prefersX-FoPost-Signature-256(HMAC over{timestamp}.{body}, refused past a 300s tolerance) and falls back to the body-onlyX-FoPost-Signature; both compare withhmac.compare_digest.Tests use
respxto round-trip a signed delivery throughparse_webhook→receive_one→send→mark_read, and cover a forged body, a stale delivery, the compatibility signature, a wrong event and a missing secret.ruff check,ruff format --check,mypy(strict) andpytest(138) all pass on the rebased branch.