• Webhook routes

    Solved Cloud Code
    12
    0 Votes
    12 Posts
    122 Views

    Cool. Thanks for sharing the solution here @devsleeper !

  • 0 Votes
    2 Posts
    273 Views

    Hmm, not really...

    You can get the number of sessions created in an hour with this call: https://getbraincloud.com/apidocs/apiref/#capi-globalapp-sysgetdailycounts

    But brainCloud doesn't otherwise track a concurrent session count per app.

    There are certainly 3rd party analytics packages that you could link into your client that would give you that sort of information though.

    Paul.

  • 0 Votes
    2 Posts
    282 Views

    Hi,

    Here are the steps to setting up a webhook to call a custom cloud code script in brainCloud:

    Step 1 - Write your script

    Go to Design | Cloud Code | Scripts and create your script You might want to just start with a simple script that logs the incoming parameters (see sample below) Be sure to enable the S2S callable field on the Details page.

    Step 2 - Declare the webhook and link it to your script

    Go to Design | Cloud Code | WebHooks and create your webhook Link it to the script that you just wrote. If you don't see your script in the list, double-check the state of the S2S callable field You can optionally restrict the webhook to be callable via a range of ip ranges (good for additional security) Click [Save] and copy the webhook URL that gets generated

    Step 3 - Go to the external service, and give it your webhook URL

    This step varies by service of course.

    Step 4 - Trigger the webhook to test

    This also varies by service. You could use Postman to do it as well.

    Step 5 - Confirm the structure of the incoming parameters

    It is a bit difficult to figure out what a webhook will send you ahead-of-time The simplest is to invoke the hook, and then examine the results See the sample logging script below for an example Then view the logged input data via Monitoring | Global Monitoring | Recent Errors. Be sure to enable Info -level messages, and click [Refresh]

    Step 6 - Complete the writing of your script

    Now that you know how the parameters are being sent, you should be good to complete your script. More info on webhook development here - https://getbraincloud.com/apidocs/apiref/?cloudcode#cc-ccscripts-webhooks Good luck!

    Sample script - just dumps parameters:

    var response = {}; bridge.logInfoJson("Script invoked from webhook. Contents of data...", data); // Return the webhook response response.statusOverride = 200; response.jsonResponse = {}; response;

    Note - you can also view the request sent and response received from your webhook via the Server Logs. For more information on brainCloud logs - see this knowledge base article.

    Hope that helps!

    Paul.