This article will describe how to send an application message via API to an external system. 


Sometimes you might want to let Barium Live send information to another system. This can be useful in a variety of different applications. For example, in an onboarding application when you want to add a user to the AD. Or, if you want to send specific data to a billing system, you can do so via the Send Application integration.  



In order to use the Send application message feature, it needs to be activated on the contract. Please contact sales@barium.se to activate this function.    


1. In Space settings navigate to the Business components tab and select Add new. Then, choose Send Application.



2. Open your process in the modeling tool and add a message intermediate to the process.  Read more about Message intermediate here.


3. Right click on the message intermediate and choose Configure message, then navigate to the Other message tab.




4. Add a queue name and a message. One example is to use this to retrieve data from a field in a form. You can achieve this by typing $form.field$. Then, select Copy queue name  and past it into the agent.xml file  (See step 5).   



Note: Messages that have been fetched from queue will be deleted after 30 days. Messages that have not been fetched from the queue within a year will automatically be deleted.


5. Now it's time to configure the API call. Either by BIA (Barium integration Agent) or a regular API Call.

In this article we will focus on configuration in the BIA (Agent.xml). If you wish to do a regular API call, you can find the API method for application message here


Example of BIA configuration: 


<?xml version="1.0" encoding="utf-8" ?>

<agent version="1.0">

    <config id="Config1" enabled="true">

        <apiurl>https://live.barium.se/api/v1.0</apiurl>

        <apikey>00000000-0000-0000-0000-000000000000</apikey> <!-- Your private API Key -->

        <apiusername>integration@company.se</apiusername>

        <apipassword>****************</apipassword> <!--Your top secret password -->

        

        <datasources>

            <datasource id="SIGNAL1" adapter="applicationmessage">

                <!--DomainId is the 4 digit number of the space.--> 

                <queryurl>https://live.barium.se/api/v1.1/domains/<domainId>/applicationmessages</queryurl>         

                <method>POST</method>

                <body>

                     <!--Add the copied "Full queue name" from step 4 here.-->

                    { "queueName" : "38c7c39b-abd5-4f81-96f1-2310a3c838d1.test_queue" }    

                </body>

            </datasource>

        </datasources>


        <triggers>

            <trigger id="trg" type="timer">

                <period>0.00:05:00</period> <!-- Set the time how often the queue will be read.-->    

           </trigger>

        </triggers>


        <tasks>

            <task trigger="trg" enabled="true">

                <query id="signal1_queue" datasource="SIGNAL1"></query>

                <foreach queryid="signal1_queue" as="queue_row">

                    <log>Signal received from Barium Live with data: id = $queue_row.id$, name = $queue_row.name$</log>

                </foreach>

            </task>

        </tasks>

    </config>

</agent>