Can you log in twice simultaneously to HipChat/XMPP chat? - xmpp

I'm building a HipChat bot, but it needs to play the role of the user WHILE the user is also logged in. Is this possible by logging in twice, once as me, the second time as the bot. Does one login get booted out?
Use case
1) User logs in
2) Bot logs in (user has given the bot its credentials)
3) Bot detects something interesting user has said
4) Bot interjects with some meta data (in effect impersonating the user)
Is this possible? Currently I have only gotten as far as interacting with the bot as separate user agent.

Related

Is it possible to programmatically send a picture in Messenger under my own user name?

I'd like to write a script which, when run, will run some program which creates a .jpg file, and then I'd like to send that as an image message over Facebook Messenger to a given user.
Note that my use case is a matter of simple automation. This should all happen under my own user ID, i.e. it would be using my user access token, I would be sending the message to a Messenger group that my user is already a member of, etc. So this is not a question about making a Facebook app that would be accessible to others; the context is strictly behaving as my own user ID.

Can't use test user to access Facebook page with Messenger Bot app

I am trying to setup my first Facebook bot by following this sample project in Glitch, connected to this quick start help page.
I have logged in with a real user, then created an app and added a messenger product as per the instructions. I have set the webhook, I have also created a page with this user, and subscribed the messenger bot to it using the app dashboard.
I can access the page with the real user and I can send messages to the page and the bot responds to those messages as expected. So far so good.
Now I would like to create test users, so that I can access this page and send messages with other users. I have followed the procedure indicated here to create such test users.
The problem is that those test users can't access the page: "Sorry, this content isn't available right now"
I have found this and this answers, which both point to this explanation.
Basically, the page the bot subscribes to must be created by one of the test users with manage_pages and pages_messaging permissions. Like this I can create other test users which can connect to the test page and send messages just fine. However, the bot is not properly subscribed to this new test page, despite following the provided steps. I followed all of them and got the success response in the subscription step:
https://graph.facebook.com/v2.9/me/subscribed_apps?method=POST&access_token=<TEST_USER_PAGE_ACCESS_TOKEN>
Still, the bot is not connected to the test page. I can send messages back and forth between test users on the test page, but the bot does not respond and I get no activity logs in the webhook.
In a nutshell:
If I create a page with a real user, I can subscribe the bot successfully to the page, but I can't access the page with test users.
If I create a page with a test user, I can access the page with other test users successfully, but I can't subscribe the bot to the page.
How can I solve this or at least troubleshoot it?
Facebook API v2.9
The test user cannot access your real facebook page but you can message your bot (logged in as a test user) via the messenger short link (m.me/your_bot_link).
I used that in the testing steps (and video screencast) for the app permissions review submission.

It is possible to remove user message from Facebook Bot chat?

I need some feature to remove user input message from conversation with my facebook bot.
I need to make authorization routine with my server application, because it working with private user information.
Therefore I want to make prompt of user password and of course it must be removed from the chat or replaced with ******.
How to handle this kind of scenario via Facebook Bot Chat ?
If it impossible, can anyone suggest me a workaround to this problem ?
Many thanks
I tried to find a way to delete a message / conversation from Facebook bot chat via Facebook apis but was not able to find a way or a specific api to delete message / conversation.
However for this particular scenario Facebook has given a way to authenticate a user with our own system with. https://developers.facebook.com/docs/messenger-platform/account-linking
So you could use this to authenticate a user with your system with login process and unauthenticated with logout process.
Hope this helps for others who has similar thoughts.

pyrocms social module: how to register new user with facebook connect

I'm still new to CI and PyroCMS, and am trying to implement a Facebook login using the Social module in a custom module, which looks like it does everything I want, but I'm clearly missing some basics (I can't find any documentation other than the brief readme)!
So far, I've watched the intro video, and have enabled Facebook successfully. I can connect via FB and see FB listed in /social/linked, but some confusion exists in my mind between the two user groups I've got: admin and user.
The flow I'm trying to construct is:
user arrives at the site and is presented with a survey
user fills in the survey, then is asked to signup (I understand that this is unconventional)
/signup has a facebook connect button, supplied by the social module
user clicks the connect button, and grants permission in facebook's popup window
user should be directed back to /signup, (or maybe redirected to /user/registration) with some details filled in from facebook (eg. email, name)
on submit, user should be added to the users table, as a member of the 'users' group (not admin) with no email activation required
an email is sent, thanks page is displayed
on returning to the site, the user should access their on-site profile using facebook connect.
I've read a bunch of threads on the subject, which have shaped these expectations...
Here's where I'm at:
user arrives, fills in survey, clicks the connect button
user is redirected to the homepage, which displays a standard page (not handled by my module). I need to return to /signup!
Based on this, I've tried setting:
$this->session->set_userdata('redirect_to', '/signup');
in what I believe is the correct controller method (checks to see if the user is logged in before sending the email, then calls template build to display the social buttons), to no avail.
(edit: I now see that the code above relates to the user module, not the social module.. maybe i can transplant some changes...)
My questions:
am i on the right track, or going about this the wrong way?!
am i right in thinking that the FB account will be matched with an existing user if the email addresss exists in the system?
I have only one FB account, which I is authorised for the app, and I'm using to connect with as a user - will this work, or do I need a separate FB account to test as user?
Other notes:
I am testing the site in Chrome, logged in as admin in Firefox.
Facebook is my testcase, I'm looking at supporting FB, LinkedIn, google and Twitter eventually.
Phew! Grateful for any feedback, Tim
I will try to answer some of your questions since i'm currently experimenting with the exact same social module as well and with some addons to it.
am i right in thinking that the FB account will be matched with an
existing user if the email addresss exists in the system?
Yes you are. I checked it myself while troubleshooting the fact that my google (gmail address) could'nt connect while my hotmail (registered email) could. You will have to sync your emails in all your social sites, change the loginsystem (allowing username login for example) or manually connect multiple emails in your account settings..
I have only one FB account, which I is authorised for the app, and I'm using to connect with as a user - will this work, or do I need a separate FB account to test as user?
I suggest u let someone with another FB account test the system (better save then sorry) but in my case I didn't have any troubles using other (normal) accounts to log in.
am i on the right track, or going about this the wrong way?!
This was your first question, but I'll answer this as the last on since I didn't test is myself:
The Facebook App has a setting called "Site URL". This is the url to which will be redirected. Simply change it to the page you wish it to be. You can also try to change the following lines in social/controllers/social.php:
Line 245 (redirect: user is logged in after FB connect)
redirect($this->input->get('success_url') ? $this->input->get('success_url') : 'social/linked');
Line 283 (redirect: user has to fill in some additional fields to complete registration)
redirect('users/register');
Good luck!
The intro video shows off the entire extent of the social module. Frontend registrations, frontend user account linking, and backend account linking for the entire system.
If you wish to integrate custom functionality, custom user flows and other stuff as listed in your question then you will need to do a little custom work with the module. Hack it, extend it, send in some pull requests, whatever, but sadly it cannot do "everything to integrate with everywhere ever" out of the box. :-/

Multi login using Facebook, Twitter, and internal login issue

I am creating an app in which you can login via Facebook, Twitter, or our own internal mechanism. The issue is the following scenario:
I open the app and login using Facebook
I logout
I open the app and login using Twitter
The above scenario will result in me as a user having two accounts in the system. How do I prevent this from happening so that I have one account and it doesn't matter whether I login using Facebook/Twitter?
Every time a user login using Facebook I am as well creating an internal account, with the Facebook username and Facebook id as password. The same thing when I login using Twitter I am creating an internal account with the Twitter user name and id as password.
An idea came in my mind to solve this:
When a user logs in using Twitter check the name and email if a user with that information already exists in the database. However, the name and email they use in both Facebook and Twitter might not be the same, so this might not work all the time.
You can't make this work with your current flow (when the user logs in then logs out again). Instead you should allow a user to login with either their Facebook or Twitter credentials and then, whilst they're still logged in, get them to associate their account with their other service with that user.
So, the flow would be something like:
New user arrives at site User logs in with Facebooks oauth2
mechanism
Your server receives their FB ID and generates a new user
in your systems. Stores their FB ID against that user.
You prompt
the user to add their twitter auth credentials. User logs in with
Twitter oauth2 mechanism
Your server receives their twitter ID,
checks to see if a user is currently logged in with your
application. Because there is, you save the twitter ID agains the
current user.
Later, the user can log out and then log in with either service.