Developing an agent application

Setup

Allow some time after registering the agent application. The identity profile of the agent is being created in the background and can take between 5 and 10 minutes

Build

  • Open the cloned repo in VS Code

  • Open integrated terminal

  • npm install

  • Create a .env file at the project root with the following:

    ###############################################################################
    # This file contains secrets - don't commit or share it!
    ###############################################################################
    
    # Specify an iModel
    CONTEXT_ID=
    IMODEL_ID=
    
    # OIDC configuration
    # Don't forget to add <CLIENT_ID>@apps.imsoidc.bentley.com to your CONNECT project. This can be done in the "My sample iModels" page.
    CLIENT_ID=
    CLIENT_SECRET=
    

    The values for CONTEXT_ID and IMODEL_ID can be obtained from the IDs column of the "My sample iModels" page. The values for CLIENT_ID and CLIENT_SECRET come from the Agent Application you registered during the Setup step

  • npm run build

Run

  • npm start
  • The agent will listen for changesets pushed to iModelHub
  • Use the iTwin Synchronizer to synchronize a change and exercise the agent.
  • For testing, it can often also be useful to skip the event listening and just run against a specific changeset. To do that, either run npm start -- --latest to use the latest changeset, or npm start -- --changeset=<CHANGESETID> to use any specific changeset

Next Steps

Last Updated: 12 June, 2024