Pick a variable based on if another variable is set

I want to add a var of testing to my playbook, and when that var is set to true i want var1 to be used but if its nor set to true, i want it to use var2. Is this possible?

below is a non working example but I hope it illustrates what i want it to do.

You are already in template mode so you can't use {{ }} inside {% %}, so delete the {{ }} and it will work

{% if testing == 'true' %}{{ slack_slacktesting }}{% else %}{{ slack_devops }}{% endif %}

There are some shorter version you could use:

{{ slack_slacktesting if testing == 'true' else slack_devops }}

or

{{ (testing == 'true') | ternary(slack_slacktesting, slack_devops) }}