I'm developing a chat app that use XMPPFramework and Openfire Server. When I (usn2) send message to usn1, a message has been created in ofMessageArchieve with conversationID. But after logout and login again, when chat, the new conversation has created (see image below), but I want to add this message to exist conversation. How can I do this?
Code to send message:
let msg = XMPPMessage(type: "chat", to: XMPPJID.jidWithString(getJIDFromName(stateID)))
msg.addBody(message)
msg.addAttributeWithName("id", stringValue: stream.generateUUID())
stream.sendElement(msg)
Although I changed Openfire as #Shoaib Ahmad Gondal suggested. It still happens
MessageId and ConversationId is not same. MessageId generates for each message you send but ConversationId generates based on users & session(maybe). To keep them same you have to modify message archive plugin or develop new one.
Related
I am sending a message on an existing conversation to my MS Teams Chatbot from outside i.e. a Windows Forms Application.
ChannelAccount userAccount = originalActivity.From;
ChannelAccount botAccount = new ChannelAccount("GenerateReport", "AzureFunction");
var message = new Activity();//Microsoft.Bot.Schema.Activity.CreateEventActivity();
message.Type = ActivityTypes.Message;
message.From = originalActivity.Recipient; //new ChannelAccount("GenerateReport", "AzureFunction");//botAccount;
message.Value = originalActivity;
((Activity)message).Text = "LongOperationResponse";
message.Recipient = originalActivity.From;// userAccount;
message.ChannelId = originalActivity.ChannelId;
message.Conversation = originalActivity.Conversation;
ResourceResponse response21= await connectorClient.Conversations.SendToConversationAsync((Activity)message);
The message activity is sent successfully and the message appears in the chat bot conversation.
I would also like to somehow trap the event when the above message is received by the ma teams chatbot.
I have attached the following Event handlers in DialogBot class that inherits from ActivityHandler class.
OnMessageActivityAsync
OnEventActivityAsync
OnTurnAsync
However, none of the above event handlers get triggered when the message is sent from outside the bot using the above logic.
These event handlers get triggered only when a user types a message in the chatbot.
Which event should get triggered when an outside message is received by the team's chatbot and how do I handle the event.
Please help.
Thanks
Gagan
The question was a bit unclear, but reading the comments now I think I understand it better. You are sending messages as the bot, but from outside of the bot (basically pro-active messaging). As a result, your bot code won't get notified at all because from Bot Framework's perspective, why would it tell you that you are sending a message - you'd know that already, of course. In practice, you will only get notified:
when a message is sent to your bot
that is further defined depending on conversation type. For a 1-1, you will get ALL messages TO your bot. For a group chat or Teams channel conversation, you will only get messages where you bot is #mentioned
I'm accessing page conversations and their messages using this reference: https://developers.facebook.com/docs/graph-api/reference/v8.0/conversation
My steps are:
v8.0/{page_id}?fields=conversations
This returns a list of conversation IDs i.e t_1000000000, t_200000000...
v8.0/t_1000000000?fields=messages{message}
This returns all messages in the conversation, however sender ID is not available - I can't tell if the page sent it or the user sent it.
What's the best way to get the sender ID for each message?
I can get sender ID from:
v8.0/t_1000000000?fields=senders, but how do I use this to filter messages?
Thank you
t_10217618258955338?fields=messages{message,from,id}
I'm following the documentation and trying to create a room:
//Create a MultiUserChat using a Connection for a room
MultiUserChat muc = new MultiUserChat(conn1, "myroom#mycompany.com");
// Create the room
muc.create("testroom");
// Send an empty room configuration form which indicates that we want
// an instant room
muc.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));
When I go into PSI, click service discovery, click multiuserchat, right click browse, click myroom. It pops an error message, that says "There was an error getting agents for myroom#mycompany.com, Reason: Feature not implemented. The feature requested is not implemented by the recipient server and cannot be processed".
Any suggestions, anyone?
Now I can create a new room using PSI. I also tried muc.join instead of muc.create. Same error message.
Without knowing your exact setup, I would guess that your room name (myroom#mycompany.com) is incorrect. You get a Feature not implemented because the XMPP entity mycompany.com does likely not act as MUC service. Those are implemented as separate XMPP component, usually named conference or muc, e.g. conference.mycompany.com.
Few questions around getting Chat working with Smack (3.2.1)/Openfire(3.7.1Alpha).
I am currently testing it using a unit test. My unit test creates a connection, creates account, logs in, adds a new user to its roster, attempts to send a chat message to the new user and eventually deletes the users. Apart from my confusions around getting chat to work, others seem to work (verified using openfire admin dashboard).
A. When I do the following
public void sendChatMessage(String sender, String receiver, String message) {
Chat chat = chatManager.createChat(receiver, messageListener);
chat.sendMessage(message);
}
Current connection is of the 'sender' (i.e. sender is logged in) and my attempt is to send a message to 'receiver'. When I get callback in my listener, message.getFrom() returns the 'receiver' and message.getBody() returns null. I am obviously trying to send a message on behalf of 'sender' to 'receiver'. What am I missing?
B. My 'sender' and 'receiver' are simply unique 'usernames' (without
any #domain) and my server is simply 'localhost'.
connection = new XMPPConnection("localhost");
Do I need to modify the 'receiver' to be of different value to make it a valid JID (there are no errors at the moment)? What if I change my server (& the openfire server configurations)?
C. I am assuming there will always be one XMPPConnection per user? Is this correct?
D.
XMPPConnection.DEBUG_ENABLED = true;
When I have XMPPConnection in debug mode, a new window opens up, however, it is tied with my IDE. How can I have it not tied to the ide so I can look into the logs while trying to debug the code?
I'm building an ejabberd module to send carbon copies of messages to an external RESTful API. Everything works okay, and requests to that API are sending POST params with Sender, Recipient and the message Body.
I'm triggering the user_send_packet and user_receive_packet hooks for this, and I can extract the params (Sender, Recipient, Body) from the packet:
Sender = xml:get_tag_attr_s("from", Packet),
Recipient = xml:get_tag_attr_s("to", Packet),
Body = xml:get_path_s(Packet, [{elem, "body"}, cdata])
For group chats (MUC) I'd also like to send the MUC roster (participants) in a parameter, but I don't know how to access them.
Is there an event for this? Can anyone point me to some documentation?
Thanks in advance!
It seems that you want to get MUC participants of specific room.
You need to look at mod_muc.erl and mod_muc_room.erl.
I'm not sure which version of ejabberd you use, so I will explain based on latest ejabberd.
After getting pid of room by calling
mnesia:dirty_read(muc_online_room, {Room, Host})
you can call
gen_fsm:sync_send_all_state_event(Pid, {get_disco_item, From, Lang}, 100)
or use similar code. User list is in the reply.
If you don't like reply format, you may want to add custom handle_sync_event to mod_muc_room.erl .