Wordpress integration

We are thinking through an integration of RC with WP - main ideas are:

  • WP will be configured to require all users to be registered/logged in.
  • We’d want to then deploy LiveChat on our WP site, and have a Hubot (or some other bot) that is logged into our RC to be appointed as the agent for that LiveChat.
  • Users can then interact with the bot via that LiveChat.

So far so easy…

Next step gets trickier - we need that bot to know the user’s identity - in the same way that the bot would know their identity if the user had DMed them from within RC, rather than from a LiveChat instance. THis enables the bot to personalise the content and scripting it uses to talk with that LiveChat user.

I think that this should be achievable by using OAuth - either we have RC relying on WP for login, or potentially we do it the other way so that WP relies on RC. Either way, because the user must login before accessing LiveChat, we should be able to pass the bot a user ID that it can use to personalise the messaging.

Is this possible in practice? Has anyone done anything like this before?

hi there @Foxy,

yes it’s possible to do that. I think the main issue here is to have WordPress users logged into RocketChat with their own WP account trough OAuth.
I think once the user is logged in into rocketchat and starts a new livechat session, livechat script will identify it’s “@username” and send livechat messages using it. If not, livechat will create an user called “@guest-123”, which can be changed by a bot using the proper method calling I think, once the bot recognizes that the username starts with “guest-”…

we have some chatbot trough livechat stuff working in HubotNatural https://github.com/RocketChat/hubot-natural if you wanna check it out…

Thanks Diego, Hubot Natural looks pretty interesting, I will take a look at that!

Re OAuth - we have a ‘Rocket.Chat first’ approach and would want Wordpress to make use of RC accounts via OAuth, not the other way. Do you know has anyone actually succeeded in setting this up yet? I know there is various capabilities already build into RC for OAuth but have not fully explored those options yet…

The main thing I’m unsure about is how to pass the user ID back to RC from the Wordpress LiveChat…

Well, maybe that can be even easier…
Rocket.Chat has an OAuth provider, so it can easily be configured as your main login provider.
WordPress in another hand needs a plguin to do it, don’t actually know any one to recomend, but any custom OAuth plugin ( like this https://br.wordpress.org/plugins/miniorange-login-with-eve-online-google-facebook/) would do the work…
Then I think once the user is ‘logged in’ in RocketChat, even through WordPress OAuth plugin, a session will be created at the browser, and if you past a livechat script inside a page, that user would access livechat as a logged in user in Rocket.Chat.
Never done it though, just speculating here, I think it worth trying…

best regards

1 Like