I see something on CLI about notification channel.
But i didn't find clear documentation on which notification we can create per API and the full scope of that function.
is it the Alert function that is available on Genesys Cloud ?
Because even on API document or on Developer tool, there is no real sample about that.
The notification commands follow the same APIs we use for the notification service. I will actually be covering how to watch notifications using the CLI in the devcast today. Here is a preview of the commands today:
//Put this in a file called create-subscription.json
[
{
"id": "v2.users.3c57c76a-3e96-424a-a6c1-1706b64bf9dc.activity"
}
]
//Creates a channel and returns the channel id. Usually starts with the streaming-as the prefix
gc notifications channels create
cat create-subscription.json | gc notifications subscriptions subscribe <<CHANNEL-ID>>
gc notifications channels listen <<CHANNEL-ID>>
Thanks,
John Carnell
Manager, Developer Engagement
I don't have a good answer yet so let me play around with the streaming in general and make sure there are no problems there. Once I can confirm in works with Linux, I will take a crack at with Windows and Powershell.
I then moved myself on queue and could see the INTERACTING status being printed to the screen. So, I was able to filter on a running stream in Linux. I am going to talk to our internal IT group that manages our internal GenesysCloud instance as they do a boatload of PowerShell and they might be able to help provide an example.
On a side note: I noticed that it is very irritating to get the heartbeats streamed out on the notification when I am streaming data as a single command filter tool like jq tries to parse them. I am going to talk with my team and see if we should provide a flag that will allow you to suppress heartbeat messages or at least write them out to stderr.
Thanks and have a good weekend.
John Carnell
Manager, Developer Engagement
Cool. JQ is powerful but can be a little painful at times. Believe me, I have had my own struggles with it (though I love the tool). If you are willing to share your code snippet when it's done, I would love to put it in our GitHub Recipes repo. I can add it or if you want PR's are welcome.
I have tried multiple things, and i really do not manage to get that command works properly...
Will have a look later if i need it, but for the moment seems to be stuck...
I think I might have located someone in our Manila team who has done a little bit of Powershell :). I am going to open a ticket with him and see if he can figure out how to do what you are asking with Powershell. I can't guarantee a timeline on when he would even start on it, but I figured I would toss it over to him and see if he could come up with something.
I know we have Powershell needs in our Dev community and I would love to get a few examples of the CLI with it to help serve those.
Thanks,
John Carnell
Manager, Developer Engagement
Are you getting any errors or does it just freeze without outputting anything?
If it's the latter, then are you using Powershell 5 or lower?
If so, that might be the reason. Streaming behaves differently than what you might expect form *nix shells and cmd.
Basically with PS(<=5) it tries to collect the outputs into memory first before piping it but since the external program gc is in a loop standard printing events as they come in, it never gets to the next command (jq)
To get the desired behavior, there are two relatively easy alternatives:
Use the newer PowerShell Core (version 7). This behavior has been fixed for these newer versions and piping the streaming data should work as expected.
I recommend this approach because installing PowerShell 7 doesn't replace your current PowerShell - it's designed to live with them side by side - So you can use both as you please.
If for some reason, this is not possible in your setup then you can also,
Invoke the good old cmd to run the command inside Powershell.
This can be as simple as adding this line at the end of your PS script:
In this example I have a variable containing the channel Id and a simple jq that gets the routing status of a user. cmd doesn't like single quotes so as you can see I have double double quotes (escaped double quotes) for the jq expression.
Prince didn't mention this, but he does have several examples of PowerShell scripts in our quick hits repo. If you have a chance take a look at it. @anon28885283 thanks for putting together these examples.
Thanks,
John Carnell
Manager, Developer Engagement
a simple line like that gc notifications channels listen streaming-0-imnrecc0rsnkudkipcg7plofm1 | jq -c '.eventBody.data[].metrics[] | select(.metric == "oWaiting") | .stats.count'
give me waiting calls on queue realtime !!!
Great.
I can play more with that now !
Keep an eye out on the blog too. Prince just wrote a really nice blog post on Powershell and the gc cli Windows client. We are doing the content review and hope to have it posted in the next couple of days. A lot of the content in the blog post came directly from some of the questions you were asking and Prince doing research on it.
Thanks,
John Carnell
Manager, Developer Engagement