embbnux / glip-ai-bot

This is an AI Assistant Bot for Glip, using API.AI and RingCentral API
10 stars 3 forks source link

Populating a different input context based on the channel/team #11

Open saisub opened 7 years ago

saisub commented 7 years ago

Is there a way to populate different input contexts depending on which channel/team the message comes from. I am trying to respond with different messages based on who is asking -- a customer vs an employee for the same question

zengfenfei commented 7 years ago

I think so. You can check the groupId of glip message to tell which channel/team the message comes from.

If you want to know who is asking, check the creatorId of the glip message.

saisub commented 7 years ago

Hmm. I could not find a way to access that information in API.AI. Will continue looking. Alternatively is there a way to have multiple AI agents connect via the same Ringcentral API or do I have to create a Ringcentral APP for each one. Essentially I am trying to have different agents for different audiences. Can I have multiple bits in GLIP all of which are enabled via a single API.AI integration?

zengfenfei commented 7 years ago

Sorry, I'm not sure what do you mean by "that information in API.AI".

embbnux commented 7 years ago

Hi, @saisub You can create multiple APIAi instance in your app. But you need to update constructor codes in here, to pass token as a params from outside when you new a ApiAi instance.

embbnux commented 7 years ago

BTW, @saisub welcome to join our RingCentral Developers discuss group in Glip. You can talk with ours developers and PM directly. Join by here. Or search RingCentral Developers in Glip.

saisub commented 7 years ago

Can you tell me how I can assign the group ID, creator ID, etc from a glip message to parameters in an API.AI intent? I.e. how do I acess them inside API,AI. Thanks a bunch

Sai

embbnux commented 7 years ago

How about sending group ID and creator ID to API.AI by sessionId in request

saisub commented 7 years ago

I think I am missing something basic. In glip the user types something and in api.ai I have the console where I can put intents etc. I don't see how I can pass or access any of the hidden variables like group ID etc. Do I have to do some JSON hacking or use webhooks/write separate javascript or am I missing something basic

saisub commented 7 years ago

In your code I see all of these variables. Do I just have to add code inside it --- Something like if groupID =x then do y inside "send message" or is there a way to expose those variable inside the API.AI UI so that I can just add intents like

If the user sai @xyz then post abc on the xyz channel etc. The problems I am trying to solve are the following:

1.) Whenever someone says @team1 inside the everyone channel lets say--> I want to send notification to the people in team 1 by posting on the team1 channel or create an @mention for everyone in team1

2.) For a certain question I want to give different answers based on the groupID (i.e the team that it was posted in) /

I see that those variables exist in your code. Just don't know how to expose them inside API.AI's UI. Should I branch your code and try to write stuff in it? Is there a way to automatically have those values appended to everything that the user sends so that I can access them as parameters in the API.AI intents /entitys?

saisub commented 7 years ago

Some folks have talked about setting up a generic context like this for facebook for example. I wonder if we can create a glip context that gets assigned all of these values --> group ID, user ID etc. Also if we can expose glip sys parameters like group ID etc that can be changed ---> for example to send a message to team B when we get a message from team A. Don't know if any this make sense. Thanks for all your help

let apiaiRequest = apiAiService.textRequest(text, { sessionId: sessionIds.get(sender), contexts: [ { name: "generic", parameters: { facebook_user_id: sender } } ]
});

saisub commented 7 years ago

HI I was able to make changes to your code to extract the group ID of a team when there is an @team in the message and send a message to that channel. I now just need help with the following. The scenario

Somepone posts a message in team1 with a mention to team2 by saying in team 1 something like he @team2 respond to this please. I am able to send a message to the team2 (that part is working). I now would like to include the name of team1 and a link back. I can access the groupID of team from the msg.groupID but don't know how to compose a message so that a link to team1 shows up in the message I compose for team 2. Basically my message on team2 should be. Hey team2 there is an important message for you at name at team 1(link of team1)

saisub commented 7 years ago

BTW I have even succeeded in getting the link to show up in team2 in the raw form http://app.glip.com/groupID but can't seem to show it as an embedded link the link format does not seem to work

embbnux commented 7 years ago

Hi, @saisub You can send group Id or other params to API.AI by contexts. This is a example.

And the structure of my bot is: Glip ---> Your Bot -> API.AI ---> Your Bot ---> Glip.

You can set you message logics in You Bot code. And use API.AI to choice actions and generate response message.

saisub commented 7 years ago

Thanks I will give it a try. BTW as per my previous entries. I have gotten pretty close to solving the message teamB when there is a mention in teamA with a @teamB message. I can now send a message to teamB alerting them of a message in teamA. I can also include a link in that message which looks like https://app.glip.com/groupIDofteamA. I have not yet figured out how to embed the link as part of the message. I tried the link method but that does not work. It sends it to another tab in chrome.. Any thoughts of that would be great.

embbnux commented 7 years ago

I am afraid that Glip app don't support it. I will check it with my colleagues

saisub commented 7 years ago

Alternatively is there a way to @mention someone via the API. I could possibly just extract all the members of a team and send @mentions to them