1
votes

How to create a generic bot (called SUPER BOT) that acts differently depending on the named JID to it?

I don’t mean the common single bot JID strategy in XMPP, i.e. mybot@host that responds differently to each user, what I mean is:

  1. The SUPER BOT should have different behaviours depending on the JID a contact is assigned. The bot itself is unique ("SUPER BOT"), a single implementation / single script, the bot itself doesn’t have a JID, and can’t be added to anyone’s contact.
  2. A company contact should have its own JID, example: store1@host which will have the SUPER BOT behaviour. The SUPER BOT will know that it is acting under store1 data, and it will also know about the user it is interacting with.
  3. Company contacts have to be created via a web interface as normal contacts, but that are linked to the SUPER BOT (inherit SUPER BOT virtually? a new type of contact?).

Company contacts can’t have each one its own file/script in the server, instead they have to be normal contacts, the only file/script in the server will be the SUPER BOT.

Example: for my needs store1@host has to be a contact that inherits/implements the singleton SUPER BOT, and then the bot will act accordingly to store1, detecting that it is store1 due to the JID.

A user1 will add store1@host to his roster, and when engaging in a conversation, SUPER BOT will know the conversation is between store1 and user1.

Questions

  1. SUPER BOT has to be a component? A module? Protocol? What?

  2. The most important question: how the stores/companies JID act as the SUPER BOT? How to link everything together like this?

  3. How to disable direct user <-> company conversation, but instead always create a MUC room/group with the user <-> company?

A diagram to help illustrate the expected flow: Diagram to help illustrate the expected flow

My findings so far

I was thinking something like hacking the contacts and assigning groups/roles: (1) user, (2) companies, then with the Ejabberd filter hook I will intercept messages sent to users that are companies. This intercept module will actually be the SUPER BOT. But this doesn't feel right or scalable under my eyes.

PS: Although I said Ejabberd, I'm looking for a XMPP-ish way of doing it, because I still haven't decided which server to go as well.

1

1 Answers

1
votes

What you need is just a component that gets routed all traffic for their subjids (individual bots).

The best approach is to create a XEP-0114 compliant component and connect it to ejabberd. It will be able to handle any number of jid under the form [email protected].