Is there a Jami bot API avaliable?

Hi all,

I’m new to Jami and I’m looking forward to moving my home-management bot from Telegram to Jami (to avoid depending on a for profit company). But the only document I can find is a example of a Jami <-> IRC bridge. The Python wrapper seems to be undocumented. And I don’t suppose poking the D-Bus API directly is the best idea ever. Is there a way to build bots? Or is it not possible? Am I missing something?

Hi.
There is indeed several ways to do a bot:

So for now, it’s the supposed way to go.

However there is a third way to do it, introduced in Together and will improve in the next versions. Plugins

Doc (will be updated):

For now, it was mainly for video, but Aline is working on chat bots, that will be available

So yeah, if something is missing in the docs or you need more info, feel free to ping, we will complete

Sorry for bumping thread.

I managed to build my own API by staring at the DBus introspect result. It’s bare bones but good enough to build a conversational bot. Let me know if I can improve it and/or you find it helpful.

1 Like

Cool and you use swarm APIs :slight_smile:

@sblin Thanks! And thanks for your help earlier.

I’ve some questions that I haven’t figure out after playing with the DBus API.

  1. How do I mark messages as shown?
    • There’s setMessageDisplayed but I don’t know what conversationUri and status mean
  2. How to I get the display name for a user?
    • I can get display name for local accounts through getAccountDetails. But it doesn’t work for accounts that I am are talking to
  3. How do I block/ban a user from my bot?

And how are messages delivered an synced on Jami? My intuition is that text messages goes through OpenDHT. When I log into my bot account from multiple places. One on my PC and one on my dev machine. Sometimes message seems does not arrive on the dev machine. Am I not waiting long enough or I shouldn’t be logged into the same account on multiple computers?

cf ConfigurationManager.xml:

<method name="setMessageDisplayed" tp:name-for-bindings="setMessageDisplayed">
           <tp:added version="8.1.0"/>
           <tp:docstring>
             <p>Informs that a message have been read</p>
           </tp:docstring>
           <arg type="s" name="accountId" direction="in">
             <tp:docstring>
               The account ID
             </tp:docstring>
           </arg>
           <arg type="s" name="conversationUri" direction="in">
             <tp:docstring>
               A conversation uri (swarm:xxxx or jami:xxxx)
             </tp:docstring>
           </arg>
           <arg type="s" name="messageId" direction="in">
             <tp:docstring>
               The message ID
             </tp:docstring>
           </arg>
           <arg type="i" name="status" direction="in">
             <tp:docstring>
               The message status, 3 for displayed
             </tp:docstring>
           </arg>
           <arg type="b" name="success" direction="out">
             <tp:docstring>
               True if the message status was set, false if account, contact or message is unknown.
             </tp:docstring>
           </arg>
       </method>

How to I get the display name for a user?
When you got a profile for a contact (profileReceived), the profile received is a VCard file with all the infos (avatar, display name, etc) and your bot can store it/manages it

How do I block/ban a user from my bot?
removeContact() there is a ban parameter if you want to ban the user

For the sync, pretty everything is explained here: https://git.jami.net/savoirfairelinux/jami-project/-/wikis/technical/2.3.-Swarm ; If something is still unclear, feel free to ask