Skip to main content

Official Python client for the FluidTalk Handshake API — drop FluidTalk AI persona replies into your own chatbot backend.

Project description

fluidtalk (Python)

Official Python client for the FluidTalk Handshake API. Drop FluidTalk's AI persona replies into your own chatbot backend without rebuilding the HTTP/auth/multipart layer.

You keep your own orchestration (when to open a chat, when to follow up, where to send messages); this client just gives you the persona's reply in one call.

pip install fluidtalk
from fluidtalk import FluidTalk, FluidTalkError

ft = FluidTalk(
    api_key="ft_sk_...",            # scoped to one persona + engine
    own_username="@my_account",     # optional default for tracking / dedup
    # base_url="https://api-talk.fluidvip.com"  (default)
)

# A lead messaged you -> get the persona's reply and relay it on your platform
res = ft.inbound_chat(target="@john_doe", message="hey, saw your post!")
for bubble in res.replies:
    my_chat.send("@john_doe", bubble)
if res.should_send_photo and res.photo_url:
    my_chat.send_image("@john_doe", res.photo_url)

Concepts → methods

A conversation can start four ways. The builder names map to these methods (the API wire value is handled for you):

Builder name When Method
Inbound Chat the lead messages first (or an ongoing chat) ft.inbound_chat(target, message)
AI Opener your persona messages first ft.ai_opener(target)
Event Trigger a platform event fires ft.event_trigger(target, event_type, context)
Follow-up re-engage a quiet lead ft.follow_up(target)
host a local image for context ft.upload_image(path=...)

A conversation is keyed by (persona, target) — reuse the same target for the same lead and the engine keeps phase/state across turns.

Examples

# AI opener (optionally with a profile screenshot for better targeting)
opener = ft.ai_opener(target="@lead", image_path="./profile.jpg")
my_chat.send("@lead", opener.message)

# Platform event (event_type must match an Event Trigger configured in your engine)
ev = ft.event_trigger(target="@lead", event_type="story_reaction", context={"reaction": "🔥"})

# Re-engage a ghost (needs an existing conversation)
fu = ft.follow_up(target="@lead")

# Attach an image the lead sent
url = ft.upload_image(path="./incoming.jpg").url
r = ft.inbound_chat(target="@lead", message="what do you think?", image_url=url)

Results: inbound_chatChatResult(reply, replies, should_send_photo, photo_url, session_id, ignored, ignore_reason); ai_opener/event_trigger/follow_upActionResult(session_id, message, ignored, ignore_reason, continued, continued_reason); upload_imageUploadResult(url). Send replies as separate bubbles; when should_send_photo, also send photo_url.

Behaviour to handle

try:
    res = ft.inbound_chat(target="@lead", message="hi")
    if res.ignored:
        return  # duplicate lead, already owned by another account — send nothing
    for bubble in res.replies:
        my_chat.send("@lead", bubble)
except FluidTalkError as e:
    if e.status == 402:   # out of tokens (insufficient_tokens)
        ...
    elif e.status == 400: # conversation already DONE / sealed -> stop messaging
        ...
    elif e.status == 404: # no conversation yet (follow_up before any contact)
        ...
  • continued is True — the lead already had an active conversation, so the action continued it instead of opening a new one (continued_reason == "conversation_already_active"). For ai_opener the message is then "" (nothing to send — switch to inbound_chat); for event_trigger the event is folded into the ongoing chat and message is the reply.
  • One token per conversation — starting a new conversation costs one token; out of tokens → FluidTalkError(status=402). Continuing an existing conversation is free.
  • Sealed conversation — when finished, the next inbound_chat raises FluidTalkError(status=400) ("This session is DONE").

API keys are action-only: send messages and upload images, never change personas/engines/billing (that stays in the dashboard). Keep your ft_sk_ key secret.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fluidtalk-1.0.2.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fluidtalk-1.0.2-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file fluidtalk-1.0.2.tar.gz.

File metadata

  • Download URL: fluidtalk-1.0.2.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for fluidtalk-1.0.2.tar.gz
Algorithm Hash digest
SHA256 587c566b6384e58406cc662e03394bbbdc68f1eac10c42fecd002f05debdecd8
MD5 a1d3436bd033d0291b18de0a78c3a892
BLAKE2b-256 23c01e9a2886e00f78a70dbae04812400727566e174c2eaac3b973ea5422aa39

See more details on using hashes here.

File details

Details for the file fluidtalk-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: fluidtalk-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for fluidtalk-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6c17d44c3985e45fd9e3633685571bb004d22a245644638817473fe48e63f4ff
MD5 f7ed7b270f4f71265c7936e434d32b4a
BLAKE2b-256 40a22a5b61950360e3135a3d8656a92cd10971fe300c7966936d561392626933

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page