Project

General

Profile

Chat bot as component

Jesper Findahl
Added over 4 years ago

Hi,

We are trying to find the best way to develop a chat bot that can participate in MUC rooms (brief description). Ideally we would like to have it as a component that is started at the same time as the server. The issue we are having is that it seems a component does not get a rooster associated with it (could not find it in the DB) and it cannot send the presence stanza - it is dropped because of no TO-address.

An alternative solution would be to develop a custom client, however, we are not sure if it could be started the same way as a component... any suggestions?

Thanks!

Jesper


Replies (4)

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam over 4 years ago

Why do you need a roster for the component/muc bot? The component can send a presence stanza, I do not see any reason why it couldn't. When a component sends a stanza it can set whatever it needs/wants in the to/from address and any payload.

Do you have any specific errors?

Added by Jesper Findahl over 4 years ago

Thanks for the quick reply and motivation that it is possible!

I managed to get the component/muc bot to join a group chat by invitation from the client. I guess for the presence stanza the component has to maintain its own rooster to know where to send the presence stanzas and notify it is online.

I try to make the component echo the group message received from a client, however, this gives an exception (I send the same stanza as the client does):

2014-10-10 16:42:15.488 [in_0-test-component]  TestComponent.processPacket()  FINEST:   IN packet: from=null, to=null, DATA=<message xmlns="jabber:client" from="hello@muc.xmpp-local/chat-test" type="groupchat" to="test-component@xmpp-local"><body>some message</body></message>, SIZE=152, XMLNS=jabber:client, PRIORITY=NORMAL, PERMISSION=NONE, TYPE=groupchat
2014-10-10 16:42:15.488 [in_12-message-router]  MessageRouter.processPacket()  FINEST:  2. Packet will be processed by: sess-man@jespers-macbook-pro.local, from=null, to=null, DATA=<message xmlns="jabber:client" from="hello@muc.xmpp-local/chat-test" type="groupchat" to="chat-test@xmpp-local/Jespers-MacBook-Pro"><body>some message</body></message>, SIZE=167, XMLNS=jabber:client, PRIORITY=NORMAL, PERMISSION=NONE, TYPE=groupchat
2014-10-10 16:42:15.489 [in_12-sess-man]   SessionManager.walk()              FINEST:   XMPPProcessorIfc: MessageAmp (amp)Request: from=null, to=sess-man@jespers-macbook-pro.local, DATA=<message xmlns="jabber:client" from="hello@muc.xmpp-local/chat-test" type="groupchat" to="chat-test@xmpp-local/Jespers-MacBook-Pro"><body>some message</body></message>, SIZE=167, XMLNS=jabber:client, PRIORITY=NORMAL, PERMISSION=NONE, TYPE=groupchat, conn: user_jid=chat-test@xmpp-local/Jespers-MacBook-Pro, packets=72, connectioId=c2s@jespers-macbook-pro.local/127.0.0.1_5222_127.0.0.1_59892, domain=xmpp-local, authState=AUTHORIZED, isAnon=false, isTmp=false
2014-10-10 16:42:15.489 [in_12-sess-man]   SessionManager.walk()              FINEST:   XMPPProcessorIfc: MessageCarbons (message-carbons)Request: from=null, to=sess-man@jespers-macbook-pro.local, DATA=<message xmlns="jabber:client" from="hello@muc.xmpp-local/chat-test" type="groupchat" to="chat-test@xmpp-local/Jespers-MacBook-Pro"><body>some message</body></message>, SIZE=167, XMLNS=jabber:client, PRIORITY=NORMAL, PERMISSION=NONE, TYPE=groupchat, conn: user_jid=chat-test@xmpp-local/Jespers-MacBook-Pro, packets=72, connectioId=c2s@jespers-macbook-pro.local/127.0.0.1_5222_127.0.0.1_59892, domain=xmpp-local, authState=AUTHORIZED, isAnon=false, isTmp=false
2014-10-10 16:42:15.489 [in_0-message-router]  MessageRouter.processPacket()  FINEST:   Processing packet: from=sess-man@jespers-macbook-pro.local, to=c2s@jespers-macbook-pro.local/127.0.0.1_5222_127.0.0.1_59892, DATA=<message xmlns="jabber:client" from="hello@muc.xmpp-local/chat-test" type="groupchat" to="chat-test@xmpp-local/Jespers-MacBook-Pro"><body>some message</body></message>, SIZE=167, XMLNS=jabber:client, PRIORITY=NORMAL, PERMISSION=AUTH, TYPE=groupchat
2014-10-10 16:42:15.490 [in_0-message-router]  MessageRouter.processPacket()  FINEST:   1. Packet will be processed by: c2s@jespers-macbook-pro.local, from=sess-man@jespers-macbook-pro.local, to=c2s@jespers-macbook-pro.local/127.0.0.1_5222_127.0.0.1_59892, DATA=<message xmlns="jabber:client" from="hello@muc.xmpp-local/chat-test" type="groupchat" to="chat-test@xmpp-local/Jespers-MacBook-Pro"><body>some message</body></message>, SIZE=167, XMLNS=jabber:client, PRIORITY=NORMAL, PERMISSION=AUTH, TYPE=groupchat
2014-10-10 16:42:15.490 [in_0-c2s]         ConnectionManager.writePacketToSocket()  FINEST: c2s@jespers-macbook-pro.local/127.0.0.1_5222_127.0.0.1_59892, type: accept, Socket: TLS: c2s@jespers-macbook-pro.local/127.0.0.1_5222_127.0.0.1_59892 Socket[addr=/127.0.0.1,port=59892,localport=5222], jid: chat-test@xmpp-local/Jespers-MacBook-Pro, Writing packet: from=sess-man@jespers-macbook-pro.local, to=c2s@jespers-macbook-pro.local/127.0.0.1_5222_127.0.0.1_59892, DATA=<message xmlns="jabber:client" from="hello@muc.xmpp-local/chat-test" type="groupchat" to="chat-test@xmpp-local/Jespers-MacBook-Pro"><body>some message</body></message>, SIZE=167, XMLNS=jabber:client, PRIORITY=NORMAL, PERMISSION=AUTH, TYPE=groupchat
2014-10-10 16:42:17.490 [in_0-test-component]  TestComponent.processGroupChatMessageStanza()  FINEST: OUT packet: from=null, to=null, DATA=<message type="groupchat" to="hello@muc.xmpp-local"><body>some message</body><nick xmlns="http://jabber.org/protocol/nick">test-component</nick></message>, SIZE=154, XMLNS=null, PRIORITY=NORMAL, PERMISSION=NONE, TYPE=groupchat
2014-10-10 16:42:17.490 [in_12-message-router]  MessageRouter.processPacket()  FINEST:  Processing packet: from=null, to=null, DATA=<message type="groupchat" to="hello@muc.xmpp-local"><body>some message</body><nick xmlns="http://jabber.org/protocol/nick">test-component</nick></message>, SIZE=154, XMLNS=null, PRIORITY=NORMAL, PERMISSION=NONE, TYPE=groupchat
2014-10-10 16:42:17.491 [in_12-message-router]  MessageRouter.processPacket()  FINEST:  1. Packet will be processed by: muc@jespers-macbook-pro.local, from=null, to=null, DATA=<message type="groupchat" to="hello@muc.xmpp-local"><body>some message</body><nick xmlns="http://jabber.org/protocol/nick">test-component</nick></message>, SIZE=154, XMLNS=null, PRIORITY=NORMAL, PERMISSION=NONE, TYPE=groupchat
2014-10-10 16:42:17.492 [in_4-muc]         AbstractMessageReceiver$QueueListener.run()  SEVERE: [in_4-muc] Exception during packet processing: from=null, to=null, DATA=<message type="groupchat" to="hello@muc.xmpp-local"><body>some message</body><nick xmlns="http://jabber.org/protocol/nick">test-component</nick></message>, SIZE=154, XMLNS=null, PRIORITY=NORMAL, PERMISSION=NONE, TYPE=groupchat

thanks again!

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam over 4 years ago

When you send a message from your component you have to set "form" attribute in the stanza. Also you need to correct addressing for the component. It cannot be in form: test-component@domain*, where *domain is the same domain which is served by the session manager (domain for your XMPP server). This causes confusion in the stanza routing. You should use: text-component.domain as your component address in "from" and "to" attributes.

Added by Jesper Findahl over 4 years ago

That was it! Thanks!

    (1-4/4)