Different Paths for Assets for Staging and Prod

Hello Cognigy,
unfortunately we have this situation:

From now on, one of our clients needs absolute paths (like "/site/somesite/assets/img.png") for the assets.
Our Flows have links to the images in this assets folder.
Our "Staging" server understands only the local paths (like "assets/img.png").
Is it possible to have local paths in the flows and have some Output Transformer or some other trick, to automagically add absolute part of the path to all outcoming urls (which are not "https://....")?

Thank you!

Best,
Anton

Didn't find what you were looking for?

New post
Was this post helpful?
1 out of 1 found this helpful

Comments

2 comments

  • Hi Anton,

     

    Yes, you can use an endpoint transformer to replace all image URLs. Endpoints are not included in snapshots, so your production endpoint wouldn't change when you update the virtual agent with a new snapshot. Your transformer will need to know where to look and what to replace. We are doing something similar with a translate transformer, so maybe you can get ideas from its code.

     

    Iterating over all possible image URL locations in a transformer can be complex and error-prone. Maybe you can have the base URL stored in the context of your flow and refer to it everywhere when adding images to bot messages? You can send the base URL back to the flow either in a transformer or as a first message payload from the bot.

     

    In a transformer, you can intercept one of the first messages by its text, e.g. "GET_STARTED", and add a data payload to it with the base url for your images. Then, in a flow, you can catch the input.data.baseUrl and put it in the context.

     

    Do you need further help with this?

    1
  • Hi Anton,

    yes, good Idea, thank you!
    I'll use the baseURL context variable and will fill it from the frontend. Perfect.

    Best,
    Anton

    0

Please sign in to leave a comment.