title: In XMPP How to have contact JIDs that are actually "virtual bots" that inherit from a single physical "super bot"?
body: <h1>How to create a generic bot (called SUPER BOT) that acts differently depending on the named JID to it?</h1>
  
  <p>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:</p>
  
  <ol>
  <li>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.</li>
  <li>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.</li>
  <li>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?).</li>
  </ol>
  
  <p>Company contacts can’t have each one its own file/script in the server, instead they have to be normal contacts, <strong>the only file/script in the server will be the SUPER BOT</strong>.</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <h1>Questions</h1>
  
  <ol>
  <li><p>SUPER BOT has to be a component? A module? Protocol? What?</p></li>
  <li><p>The most important question: how the stores/companies JID act as the SUPER BOT? How to link everything together like this?</p></li>
  <li><p>How to disable direct user &lt;-> company conversation, but instead always create a MUC room/group with the user &lt;-> company?</p></li>
  </ol>
  
  <p>A diagram to help illustrate the expected flow:
  <a href="https://i.stack.imgur.com/IX0dS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IX0dS.png" alt="Diagram to help illustrate the expected flow"></a> </p>
  
  <h1>My findings so far</h1>
  
  <p>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.</p>
  
  <p>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.</p>