Using Custom Webhooks to Integrate with Cisco Webex App

This article shows you how to receive ThousandEyes alert notifications in a Cisco Webex App space using webhooks.
  1. 1.
    Create a new Webex bot.
    A Webex bot lets you integrate services into Webex.
    In Webex App, create a new bot to receive alert notifications from the ThousandEyes webhook. For detailed instructions, see Creating a Webex Bot. Use the screenshots below to help create your bot.
  2. 2.
    Copy the bot's access token.
    After setting up your new Webex bot, copy the bot's access token and paste it somewhere handy. You'll need this token for the ThousandEyes integration.
  3. 3.
    In Webex App, create a space to receive alert notifications from ThousandEyes.
    Skip this step if you already have a Webex App space where you'd like to receive alerts.
  4. 4.
    Add the Webex App bot to the space.
    In this example, the bot named "ThousandEyes Custom Webhook Test" is added to the "ThousandEyes-Webhook-Test" Webex App space.
  5. 5.
    Copy the space's roomId.
    You'll use the roomId with the bot's access token (from Step 2) to configure the ThousandEyes integration.
    Now that the Webex bot is a member of your Webex App space, look up the roomId of your Webex App space and copy it. To find the roomId:
    a. Use your Webex App login to access the Webex API site.
    b. Using a web browser, navigate to the following URL to look up the roomId: https://developer.webex.com/docs/api/v1/rooms/list-rooms
  6. 6.
    Create a new alert integration.
    From the ThousandEyes app, create a new alert integration using custom webhooks. The webhook integration sends alert notifications to the Webex App bot. The Webex App bot publishes these notifications as messages in the Webex App space.
    To create a new alert integration, navigate to Integrations. Click + New Integration and then select the option for Custom Webhook.
  7. 7.
    Configure your custom webhook to work with Webex App.
    ThousandEyes custom webhooks offer a preset configuration that populates the fields with the settings you need to integrate with Webex App.
    In the Preset Configurations field, select Cisco Webex.
    Fill out the other fields as follows:
    Name
    Example: "Webex App Test"
    URL
    Use the url for Webex App Messages: "https://webexapis.com/v1/messages"
    Auth Type
    Token
    Bearer Token
    Use the Webex App bot's access token (see Step 2)
    Headers
    Content-Type application/json
    Body
    Add the roomId (see Step 5) to the JSON content in the Body field, before the line that says "markdown". Create a new line, then add the following text:
    "roomId" : "<yourWebex App space roomId>",
    Replace <yourWebex App space roomId> with the roomId from Step 5. The final result should look something like the entry below.
    {
    "roomId" : "12345abcde67890fghij",
    "markdown" : "<strong>ThousandEyes Alert{{#eq type.id 2}} Triggered{{else}} Cleared{{/eq}}{{#if alert.test}} for {{alert.test.name}}{{/if}}</strong>\n<strong>Alert ID:</strong> {{alert.id}}{{#if alert.test}}\n<strong>Test Name:</strong> {{alert.test.name}}\n<strong>Target/s:</strong> {{#each alert.targets}}{{description}}{{#unless @last}} {{/unless}}{{/each}}{{/if}}\n<strong>Alert Rule:</strong> {{alert.rule.name}} - {{formatExpression alert.rule.expression}}{{#if alert.details}}\n<strong>Details:</strong> {{alert.details.size}}{{/if}}\n<strong>Severity:</strong> {{alert.severity.display}}\n<strong>Alerts Link:</strong> https://app.thousandeyes.com/alerts/list/active"
    }
  8. 8.
    Test the integration.
    At the bottom of the Add Custom Integration screen, click Test.
    A successful test returns the message Testing completed successfully! HTTP status: OK (200), as shown above.
    Verify that the "Sample Test" message shows up in the Webex App space.
    Click the Save button to save the integration.
    If the test fails, click Save to save the integration; then re-open the integration and test it again. If the test still fails, verify that the webhook URL in the ThousandEyes custom webhook matches the incoming Webex App webhook.
  9. 9.
    Apply the new integration to your alert rules.
    To edit an alert rule, go to Alerts > Alert Rules and select the alert rule. Then click Notifications > Integrations and select the integration you just created. Finally, click Save Changes.
For more information on configuring webhooks, see Alert Notifications Via Webhooks.