---
# System prepended metadata

title: IM4DEC ChatBot Conversation Sharing
tags: [im4dec]

---

# DEC112 Chatbot - Data Collection and Sharing

## Infrastructure

* **Server**
    <details><summary>Data Provider (DEC112 Chatbot)</summary>
    <ul>
      <li>URL: chatbot.staging.dec112.eu</li>
      <li>OAuth Token <code>DEC_TOKEN</code></li>
        
      export DEC_KEY="62kDy13Kvek1QEhYY64FwItCDyZ6R5cCnVDKRJ2DR1g"
      export DEC_SECRET="fbaYe9Yeo65zT1vT3afrdHoMxedT5h23Xjf6HeXNDYs"
      export DEC_TOKEN=`curl -s -d grant_type=client_credentials -d client_id=$DEC_KEY -d client_secret=$DEC_SECRET -d scope=admin -X POST https://chatbot.staging.dec112.eu/oauth/token | jq -r '.access_token'`
          
    </ul>
    </details>
    <details><summary>Data Intermediary (hostey by OwnYourdata)</summary>
    <ul>
      <li>URL: chats.go-data.at</li>
      <li>OAuth Token <code>IM_TOKEN</code></li>
        
      export IM_KEY="Z9FITOpfGHb30A9siyiGgcAwv8IQ34vqWDhW5cABhh8"
      export IM_SECRET="Kpg0pvIC-FvR3OWpUZo1egAwJVPKzGNdaEB_4yYKsEI"
      export IM_TOKEN=`curl -s -d grant_type=client_credentials -d client_id=$IM_KEY -d client_secret=$IM_SECRET -d scope=admin -X POST https://chats.go-data.at/oauth/token | jq -r '.access_token'`
          
    </ul>
    </details>
    <details><summary>Data User (simulated MoI)</summary>
    <ul>
      <li>URL: bmi-demo.data-container.net</li>
      <li>OAuth Token <code>MOI_TOKEN</code></li>
        
      export MOI_KEY="4ZCHpOU9de6OBcihuvQtNHs7fcDjweXLpZAWu4BfWe4"
      export MOI_SECRET="nA1Zgx4hDYDW1NhweeaBMlLC4FZJDzs8EviJYUwyFDw"
      export MOI_TOKEN=`curl -s -d grant_type=client_credentials -d client_id=$MOI_KEY -d client_secret=$MOI_SECRET -d scope=admin -X POST https://bmi-demo.data-container.net/oauth/token | jq -r '.access_token'`
          
    </ul>
    </details>

```plantuml
@startuml

component "chatbot.staging.dec112.eu\nimage: oydeu/dc-chatbot" <<Chatbot (Data Source)>> as chatbot
component "chats.go-data.at\nimage: oydeu/dc-intermediary" <<Data Intermediary>> as disp
component "bmi-demo.data-container.eu\nimage: oydeu/dc-base" <<Data User>> as user

chatbot -> disp
disp -> user

@enduml
```

&nbsp;

* **Identities**
    <details><summary>DEC112 (Data Source)</summary>
    <ul>
      <li>DID: <code>did:oyd:zQmefAYBcTqEizzQ1k4F7NYDjyPVqhmKWC1JBUqy5XEjKnQ</code></li>
      <li>command: <code>echo '' | oydid create --doc-pwd decpwd --rev-pwd decrev -z 1</code></li>
    </ul>
    </details>
    <details><summary>OwnYourData (Data Intermediary)</summary>
    <ul>
      <li>DID: <code>did:oyd:zQmWwtUAbJHtd2wRU5GnR3wYWrt7vBQQ7U1GPK12tEvvKtU</code></li>
      <li>command: <code>echo '' | oydid create --doc-pwd oydpwd --rev-pwd oydrev -z 1</code></li>
    </ul>
    </details>
    <details><summary>Ministry of the Interior (BMI, Data User)</summary>
    <ul>
      <li>DID: <code>did:oyd:zQmf8mUhkN73Sgwjpn1RaShyQbgVfVbGu8yYDzW7e8WGt2z</code></li>
      <li>command: <code>echo '' | oydid create --doc-pwd moipwd --rev-pwd moirev -z 1</code></li>
    </ul>
    </details>

## Governance

* User gives consent at the end of a conversation with the ChatGPT-based DEC112 chatbot
  <details><summary>Questions</summary>
    
    1. Thank you for using DEC112's chatbot! Please rate the chat on a scale from 1-bad to 10-good.    
    2. May we share your conversation with emergency response organisations for training purposes? Please answer “Yes” if you agree; any other input will be interpreted as rejection.
    3. Can we contact you via email about this chat history? Agree by entering your email address.
  </details>
* DEC112 Association provides data to intermediation service hosted by OwnYourData according to Data Agreement
  <details><summary>Domain-specific Data Agreement</summary>
  
  [show Data Agreement Form](https://soya-form.ownyourdata.eu/?schemaDri=D2A_conversation&data=%7B%22purposes%22%3A%5B%7B%22purpose_description%22%3A%22The+conversations+will+be+used+to+improve+training+for+call+takers.+All+personal+information%2C+such+as+address%2C+phone+number%2C+and+email%2C+is+removed+before+permanent+storage.%22%2C%22purpose_type%22%3A%22training%22%2C%22lawful_basis%22%3A%22consent%22%2C%22content%22%3A%5B%7B%22attribute_id%22%3A%22https%3A%2F%2Fsoya.ownyourdata.eu%2FDecChatBotSharing%3AConversation%3Atext%22%2C%22attribute_type%22%3A%22free+text%22%2C%22sensitivity%22%3A%22pii%22%7D%2C%7B%22attribute_id%22%3A%22https%3A%2F%2Fsoya.ownyourdata.eu%2FDecChatBotSharing%3Arating%22%2C%22attribute_type%22%3A%22integer%22%2C%22sensitivity%22%3A%22none%22%2C%22data_optional%22%3Atrue%7D%5D%2C%22processing_method%22%3A%22store%2C+query%2C+analyse%22%2C%22retention_period%22%3A%22%22%2C%22storage_location%22%3A%22EEC%22%2C%22geographic_restriction%22%3A%22EEC%22%2C%22recipient_third_party%22%3A%5B%7B%22party_id%22%3A%22did%3Aoyd%3AzQmf8mUhkN73Sgwjpn1RaShyQbgVfVbGu8yYDzW7e8WGt2z%22%2C%22party_name%22%3A%22Ministry+of+the+Interior%22%2C%22party_address%22%3A%22Herrengasse+7%2C+1010+Wien%2C+Austria%22%2C%22party_contact%22%3A%22%2B43+1+53+126-3100+%22%2C%22party_type%22%3A%22Authority%22%2C%22party_role%22%3A%22Third+Party%22%7D%2C%7B%22party_role%22%3A%22Data+Intermediary%22%2C%22party_type%22%3A%22Emergency+Response+Organisations%22%2C%22party_id%22%3A%22did%3Aoyd%3AzQmWwtUAbJHtd2wRU5GnR3wYWrt7vBQQ7U1GPK12tEvvKtU%22%2C%22party_name%22%3A%22OwnYourData+-+Verein+zur+F%C3%B6rderung+der+selbstst%C3%A4ndigen+Nutzung+von+Daten%22%2C%22party_address%22%3A%22Michael+Scherz-Stra%C3%9Fe+14%2C+2540+Bad+V%C3%B6slau%2C+Austria%22%7D%5D%2C%22service%22%3A%22Digital+emergency+communication%22%2C%22jurisdiction%22%3A%22Vienna%22%2C%22privacy_policy%22%3A%22https%3A%2F%2Fwww.dec112.at%2Fen%2Fprivacy%2F%22%2C%22withdrawal_method%22%3A%22email+to+office%40ownyourdata.eu%22%2C%22data_controllers%22%3A%5B%7B%22party_id%22%3A%22did%3Aoyd%3AzQmefAYBcTqEizzQ1k4F7NYDjyPVqhmKWC1JBUqy5XEjKnQ%22%2C%22party_name%22%3A%22DEC112+-+Verein+zur+Entwicklung+von+standardisierten+und+barrierefreien+Notrufen%22%2C%22party_address%22%3A%22Steingasse+3%2C+4786+Brunnenthal%2C+Austria%22%2C%22party_type%22%3A%22Association%22%2C%22party_role%22%3A%22Data+Source%22%7D%2C%7B%22party_id%22%3A%22did%3Aoyd%3AzQmWwtUAbJHtd2wRU5GnR3wYWrt7vBQQ7U1GPK12tEvvKtU%22%2C%22party_name%22%3A%22OwnYourData+-+Verein+zur+F%C3%B6rderung+der+selbstst%C3%A4ndigen+Nutzung+von+Daten%22%2C%22party_address%22%3A%22Michael+Scherz-Stra%C3%9Fe+14%2C+2540+Bad+V%C3%B6slau%2C+Austria%22%2C%22party_type%22%3A%22Association%22%2C%22party_role%22%3A%22Data+Intermediary%22%7D%5D%2C%22event_time%22%3A%222023-10-25T12%3A00%3A00%2B02%3A00%22%2C%22event_type%22%3A%22implicit%22%2C%22event_state%22%3A%22consent%22%2C%22event_entity_id%22%3A%22did%3Aoyd%3AzQmefAYBcTqEizzQ1k4F7NYDjyPVqhmKWC1JBUqy5XEjKnQ%22%7D%5D%7D)
  Content of `d2a.json`:
  ```json=
  {
    "purposes": [
      {
        "purpose_description": "The conversations will be used to improve training for call takers. All personal information, such as address, phone number, and email, is removed before permanent storage.",
        "purpose_type": "training",
        "lawful_basis": "consent",
        "content": [
          {
            "attribute_id": "https://soya.ownyourdata.eu/DecChatBotSharing:Conversation:text",
            "attribute_type": "free text",
            "sensitivity": "pii"
          },
          {
            "attribute_id": "https://soya.ownyourdata.eu/DecChatBotSharing:rating",
            "attribute_type": "integer",
            "sensitivity": "none",
            "data_optional": true
          }
        ],
        "processing_method": "store, query, analyse",
        "retention_period": "",
        "storage_location": "EEC",
        "geographic_restriction": "EEC",
        "recipient_third_party": [
          {
            "party_id": "did:oyd:zQmf8mUhkN73Sgwjpn1RaShyQbgVfVbGu8yYDzW7e8WGt2z",
            "party_name": "Ministry of the Interior",
            "party_address": "Herrengasse 7, 1010 Wien, Austria",
            "party_contact": "+43 1 53 126-3100 ",
            "party_type": "Authority",
            "party_role": "Third Party"
          },
          {
            "party_role": "Data Intermediary",
            "party_type": "Emergency Response Organisations",
            "party_id": "did:oyd:zQmWwtUAbJHtd2wRU5GnR3wYWrt7vBQQ7U1GPK12tEvvKtU",
            "party_name": "OwnYourData - Verein zur Förderung der selbstständigen Nutzung von Daten",
            "party_address": "Michael Scherz-Straße 14, 2540 Bad Vöslau, Austria"
          }
        ],
        "service": "Digital emergency communication",
        "jurisdiction": "Vienna",
        "privacy_policy": "https://www.dec112.at/en/privacy/",
        "withdrawal_method": "email to office@ownyourdata.eu",
        "data_controllers": [
          {
            "party_id": "did:oyd:zQmefAYBcTqEizzQ1k4F7NYDjyPVqhmKWC1JBUqy5XEjKnQ",
            "party_name": "DEC112 - Verein zur Entwicklung von standardisierten und barrierefreien Notrufen",
            "party_address": "Steingasse 3, 4786 Brunnenthal, Austria",
            "party_type": "Association",
            "party_role": "Data Source"
          },
          {
            "party_id": "did:oyd:zQmWwtUAbJHtd2wRU5GnR3wYWrt7vBQQ7U1GPK12tEvvKtU",
            "party_name": "OwnYourData - Verein zur Förderung der selbstständigen Nutzung von Daten",
            "party_address": "Michael Scherz-Straße 14, 2540 Bad Vöslau, Austria",
            "party_type": "Association",
            "party_role": "Data Intermediary"
          }
        ],
        "event_time": "2023-10-25T12:00:00+02:00",
        "event_type": "implicit",
        "event_state": "consent",
        "event_entity_id": "did:oyd:zQmefAYBcTqEizzQ1k4F7NYDjyPVqhmKWC1JBUqy5XEjKnQ"
      }
    ]
  }
  ```
  </details>
* OwnYourData discloses data to BMI-Demo according to Data Agreement
  <details><summary>Domain-specific Data Disclosure Agreement</summary>
  
  [show Data Disclosure Agreement Form](https://soya-form.ownyourdata.eu/?schemaDri=D3A_conversation&data=%7B%22purposes%22%3A%5B%7B%22purpose_description%22%3A%22The+conversations+will+be+used+to+improve+training+for+call+takers.+All+personal+information%2C+such+as+address%2C+phone+number%2C+and+email%2C+is+removed+before+permanent+storage.%22%2C%22purpose_type%22%3A%22training%22%2C%22lawful_basis%22%3A%22consent%22%2C%22content%22%3A%5B%7B%22attribute_id%22%3A%22https%3A%2F%2Fsoya.ownyourdata.eu%2FDecChatBotSharing%3AConversation%3Atext%22%2C%22attribute_type%22%3A%22free+text%22%2C%22sensitivity%22%3A%22pii%22%7D%2C%7B%22attribute_id%22%3A%22https%3A%2F%2Fsoya.ownyourdata.eu%2FDecChatBotSharing%3Arating%22%2C%22attribute_type%22%3A%22integer%22%2C%22sensitivity%22%3A%22none%22%2C%22data_optional%22%3Atrue%7D%5D%2C%22processing_method%22%3A%22store%2C+query%2C+analyse%22%2C%22retention_period%22%3A%22%22%2C%22storage_location%22%3A%22EEC%22%2C%22geographic_restriction%22%3A%22EEC%22%2C%22recipient_third_party%22%3A%5B%7B%22party_id%22%3A%22did%3Aoyd%3AzQmf8mUhkN73Sgwjpn1RaShyQbgVfVbGu8yYDzW7e8WGt2z%22%2C%22party_name%22%3A%22Ministry+of+the+Interior%22%2C%22party_address%22%3A%22Herrengasse+7%2C+1010+Wien%2C+Austria%22%2C%22party_contact%22%3A%22%2B43+1+53+126-3100+%22%2C%22party_type%22%3A%22Authority%22%2C%22party_role%22%3A%22Third+Party%22%7D%2C%7B%22party_role%22%3A%22Data+Intermediary%22%2C%22party_type%22%3A%22Emergency+Response+Organisations%22%2C%22party_id%22%3A%22did%3Aoyd%3AzQmWwtUAbJHtd2wRU5GnR3wYWrt7vBQQ7U1GPK12tEvvKtU%22%2C%22party_name%22%3A%22Verein+zur+F%C3%B6rderung+der+selbstst%C3%A4ndigen+Nutzung+von+Daten%22%2C%22party_address%22%3A%22Michael+Scherz-Stra%C3%9Fe+14%2C+2540+Bad+V%C3%B6slau%2C+Austria%22%7D%5D%2C%22service%22%3A%22Digital+emergency+communication%22%2C%22jurisdiction%22%3A%22Vienna%22%2C%22privacy_policy%22%3A%22https%3A%2F%2Fwww.dec112.at%2Fen%2Fprivacy%2F%22%2C%22withdrawal_method%22%3A%22email+to+office%40ownyourdata.eu%22%2C%22data_controllers%22%3A%5B%7B%22party_id%22%3A%22did%3Aoyd%3AzQmefAYBcTqEizzQ1k4F7NYDjyPVqhmKWC1JBUqy5XEjKnQ%22%2C%22party_name%22%3A%22DEC112+-+Verein+zur+Entwicklung+von+standardisierten+und+barrierefreien+Notrufen%22%2C%22party_address%22%3A%22Steingasse+3%2C+4786+Brunnenthal%2C+Austria%22%2C%22party_type%22%3A%22Association%22%2C%22party_role%22%3A%22Data+Source%22%7D%2C%7B%22party_id%22%3A%22did%3Aoyd%3AzQmWwtUAbJHtd2wRU5GnR3wYWrt7vBQQ7U1GPK12tEvvKtU%22%2C%22party_name%22%3A%22OwnYourData+-+Verein+zur+F%C3%B6rderung+der+selbstst%C3%A4ndigen+Nutzung+von+Daten%22%2C%22party_address%22%3A%22Michael+Scherz-Stra%C3%9Fe+14%2C+2540+Bad+V%C3%B6slau%2C+Austria%22%2C%22party_type%22%3A%22Association%22%2C%22party_role%22%3A%22Data+Intermediary%22%7D%5D%2C%22event_time%22%3A%222023-10-25T12%3A00%3A00%2B02%3A00%22%2C%22event_type%22%3A%22implicit%22%2C%22event_state%22%3A%22consent%22%2C%22event_entity_id%22%3A%22did%3Aoyd%3AzQmefAYBcTqEizzQ1k4F7NYDjyPVqhmKWC1JBUqy5XEjKnQ%22%2C%22data_intermediary%22%3A%5B%7B%22party_id%22%3A%22did%3Aoyd%3AzQmWwtUAbJHtd2wRU5GnR3wYWrt7vBQQ7U1GPK12tEvvKtU%22%2C%22party_name%22%3A%22Verein+zur+F%C3%B6rderung+der+selbstst%C3%A4ndigen+Nutzung+von+Daten%22%2C%22party_address%22%3A%22Michael+Scherz-Stra%C3%9Fe+14%2C+2540+Bad+V%C3%B6slau%2C+Austria%22%7D%5D%2C%22data_user%22%3A%5B%7B%22party_id%22%3A%22did%3Aoyd%3AzQmf8mUhkN73Sgwjpn1RaShyQbgVfVbGu8yYDzW7e8WGt2z%22%2C%22party_name%22%3A%22Ministry+of+the+Interior%22%2C%22party_address%22%3A%22Herrengasse+7%2C+1010+Wien%2C+Austria%22%2C%22party_type%22%3A%22Authority%22%7D%5D%7D%5D%7D)
    Content of `d3a.json`:
  ```json=
  {
    "purposes": [
      {
        "purpose_description": "The conversations will be used to improve training for call takers. All personal information, such as address, phone number, and email, is removed before permanent storage.",
        "purpose_type": "training",
        "lawful_basis": "consent",
        "content": [
          {
            "attribute_id": "https://soya.ownyourdata.eu/DecChatBotSharing:Conversation:text",
            "attribute_type": "free text",
            "sensitivity": "pii"
          },
          {
            "attribute_id": "https://soya.ownyourdata.eu/DecChatBotSharing:rating",
            "attribute_type": "integer",
            "sensitivity": "none",
            "data_optional": true
          }
        ],
        "processing_method": "store, query, analyse",
        "retention_period": "",
        "storage_location": "EEC",
        "geographic_restriction": "EEC",
        "recipient_third_party": [
          {
            "party_id": "did:oyd:zQmf8mUhkN73Sgwjpn1RaShyQbgVfVbGu8yYDzW7e8WGt2z",
            "party_name": "Ministry of the Interior",
            "party_address": "Herrengasse 7, 1010 Wien, Austria",
            "party_contact": "+43 1 53 126-3100 ",
            "party_type": "Authority",
            "party_role": "Third Party"
          },
          {
            "party_role": "Data Intermediary",
            "party_type": "Emergency Response Organisations",
            "party_id": "did:oyd:zQmWwtUAbJHtd2wRU5GnR3wYWrt7vBQQ7U1GPK12tEvvKtU",
            "party_name": "Verein zur Förderung der selbstständigen Nutzung von Daten",
            "party_address": "Michael Scherz-Straße 14, 2540 Bad Vöslau, Austria"
          }
        ],
        "service": "Digital emergency communication",
        "jurisdiction": "Vienna",
        "privacy_policy": "https://www.dec112.at/en/privacy/",
        "withdrawal_method": "email to office@ownyourdata.eu",
        "data_controllers": [
          {
            "party_id": "did:oyd:zQmefAYBcTqEizzQ1k4F7NYDjyPVqhmKWC1JBUqy5XEjKnQ",
            "party_name": "DEC112 - Verein zur Entwicklung von standardisierten und barrierefreien Notrufen",
            "party_address": "Steingasse 3, 4786 Brunnenthal, Austria",
            "party_type": "Association",
            "party_role": "Data Source"
          },
          {
            "party_id": "did:oyd:zQmWwtUAbJHtd2wRU5GnR3wYWrt7vBQQ7U1GPK12tEvvKtU",
            "party_name": "OwnYourData - Verein zur Förderung der selbstständigen Nutzung von Daten",
            "party_address": "Michael Scherz-Straße 14, 2540 Bad Vöslau, Austria",
            "party_type": "Association",
            "party_role": "Data Intermediary"
          }
        ],
        "event_time": "2023-10-25T12:00:00+02:00",
        "event_type": "implicit",
        "event_state": "consent",
        "event_entity_id": "did:oyd:zQmefAYBcTqEizzQ1k4F7NYDjyPVqhmKWC1JBUqy5XEjKnQ",
        "data_intermediary": [
          {
            "party_id": "did:oyd:zQmWwtUAbJHtd2wRU5GnR3wYWrt7vBQQ7U1GPK12tEvvKtU",
            "party_name": "Verein zur Förderung der selbstständigen Nutzung von Daten",
            "party_address": "Michael Scherz-Straße 14, 2540 Bad Vöslau, Austria"
          }
        ],
        "data_user": [
          {
            "party_id": "did:oyd:zQmf8mUhkN73Sgwjpn1RaShyQbgVfVbGu8yYDzW7e8WGt2z",
            "party_name": "Ministry of the Interior",
            "party_address": "Herrengasse 7, 1010 Wien, Austria",
            "party_type": "Authority"
          }
        ]
      }
    ]
  }
  ```
  </details>

## Process

### 1 - Data Source and Data User register at Data Intermediary

<details><summary>Data source (DEC112 Chatbot) registration</summary>
<ul>
  <li>Organization-ID: 1</li>
  <li>User-ID: 2<br>
  Client-ID: <code>Rm8istADxz3mbcdczeowD9BC4A3TV47D8h16q2CgM2o</code><br>Client-Secret: <code>JYSwnL6x6yKpDuuvmVdKJAPDZeYdygSAiIRIT3BcdIk</code></li>
  <li>Command line to create DEC112 registration and retrieve data:</li>
</ul>

```bash=
echo '{"name":"DEC112","email":"info@dec112.at"}' | \
curl -H "Authorization: Bearer $IM_TOKEN" \
    -H "Content-Type: application/json" -d @- \
    -X POST https://chats.go-data.at/organization/
# get user credentials
curl -H "Authorization: Bearer $IM_TOKEN" \
    https://chats.go-data.at/user/2/wallet
```

</details>
<details><summary>Data user (MoI) registration</summary>
<ul>
  <li>Organization-ID: 3</li>
  <li>User-ID: 4<br>
  Client-ID: <code>qhLTLMCBLZEQrDXZwxgpXNnyrBZ2Ack3lhUa5rZLilE</code><br>Client-Secret: <code>bPZGC-8oSpgpElTIIxPqCHJX19d0-uNy-RMduyadPGc</code></li>
  <li>Command line to create MoI registration and retrieve data:</li>
</ul>

```bash=
echo '{"name":"MoI","email":"fake@moi.at"}' | \
curl -H "Authorization: Bearer $IM_TOKEN" \
    -H "Content-Type: application/json" -d @- \
    -X POST https://chats.go-data.at/organization/
# get user credentials
curl -H "Authorization: Bearer $IM_TOKEN" \
    https://chats.go-data.at/user/4/wallet
```
  
</details>

### 2 - Data Source signs Data Agreement

<details><summary>DEC112 signs Data Agreement</summary> 
<ul>
  <li>DEC112 DID: <code>did:oyd:zQmefAYBcTqEizzQ1k4F7NYDjyPVqhmKWC1JBUqy5XEjKnQ</code></li>
  <li>DEC112 Private Key Password: <code>decpwd</code></li>
  <li>Command line to sign Data Agreement by DEC112:</li>
</ul>

```bash=
cat d2a.json | \
oydid vc-proof --doc-pwd decpwd \
    --issuer did:oyd:zQmefAYBcTqEizzQ1k4F7NYDjyPVqhmKWC1JBUqy5XEjKnQ \
    > d2a_DEC112-signed.json
```

</details>

<details><summary>Data Intermediary signs Data Agreement</summary> 
<ul>
  <li>Intermediary DID: <code>did:oyd:zQmWwtUAbJHtd2wRU5GnR3wYWrt7vBQQ7U1GPK12tEvvKtU</code></li>
  <li>Intermediary Private Key Password: <code>oydpwd</code></li>
  <li>Command line to sign Data Agreement by OwnYourData:</li>
</ul>

```bash=
cat d2a.json | \
oydid vc-proof --doc-pwd oydpwd \
    --issuer did:oyd:zQmWwtUAbJHtd2wRU5GnR3wYWrt7vBQQ7U1GPK12tEvvKtU \
    > d2a_OYD-signed.json
```

</details>

<details><summary>Compile and Store Verifiable Credential for Data Agreement</summary> 
<ul>
  <li>DEC112 DID: <code>did:oyd:zQmefAYBcTqEizzQ1k4F7NYDjyPVqhmKWC1JBUqy5XEjKnQ</code></li>
  <li>Intermediary DID: <code>did:oyd:zQmWwtUAbJHtd2wRU5GnR3wYWrt7vBQQ7U1GPK12tEvvKtU</code></li>
  <li>Intermediary Private Key Password: <code>oydpwd</code></li>
  <li>Verifiable Credential ID: <code>zQmW38ifd8QrU4uP8563XTDAyCCgsQEj4shHtpfKaukJTvz</code></li>
  <li>Verifiable Presentation: <a href="https://chats.go-data.at/presentations/zQmbAJWhqBTb32xqnotUyGcTuMuXNxFjaeCapBT7RHVMqfV"><code>zQmbAJWhqBTb32xqnotUyGcTuMuXNxFjaeCapBT7RHVMqfV</code></a></li>
  <li>Command line to create VC & VP:</li>
</ul>

```bash=
cat d2a.json | \
jq --slurpfile sig1 d2a_DEC112-signed.json \
   --slurpfile sig2 d2a_OYD-signed.json '{
    "credentialSubject": .,
    "proof": [$sig1, $sig2]}' | \
jq '. * {"credentialSubject": {"id":"did:oyd:zQmWwtUAbJHtd2wRU5GnR3wYWrt7vBQQ7U1GPK12tEvvKtU"}}' | \
oydid vc-push --doc-pwd oydpwd \
    --issuer did:oyd:zQmefAYBcTqEizzQ1k4F7NYDjyPVqhmKWC1JBUqy5XEjKnQ \
    --holder did:oyd:zQmWwtUAbJHtd2wRU5GnR3wYWrt7vBQQ7U1GPK12tEvvKtU \
    --location https://chats.go-data.at

# create VP
oydid vc-read zQmW38ifd8QrU4uP8563XTDAyCCgsQEj4shHtpfKaukJTvz \
    --holder did:oyd:zQmWwtUAbJHtd2wRU5GnR3wYWrt7vBQQ7U1GPK12tEvvKtU \
    --doc-pwd oydpwd --location https://chats.go-data.at | \
oydid vp-push --doc-pwd oydpwd \
    --holder did:oyd:zQmWwtUAbJHtd2wRU5GnR3wYWrt7vBQQ7U1GPK12tEvvKtU \
    --location https://chats.go-data.at
```

</details>

### 3 - Chat data is tranferred from Data Source to Data Intermediary

<details><summary>Setup Data Repository (Collection)</summary> 
<ul>
  <li>Collection-ID: 5<br>
    
    curl -H "Authorization: Bearer $DEC_USER_TOKEN" https://chats.go-data.at/collection/5
    curl -H "Authorization: Bearer $DEC_USER_TOKEN" https://chats.go-data.at/collection/5/meta

  </li>
  <li>Command line to create repo:</li>
</ul>

```bash=
# credential for DEC user
export DEC_USER_KEY="Rm8istADxz3mbcdczeowD9BC4A3TV47D8h16q2CgM2o"
export DEC_USER_SECRET="JYSwnL6x6yKpDuuvmVdKJAPDZeYdygSAiIRIT3BcdIk"
export DEC_USER_TOKEN=`curl -s -d grant_type=client_credentials -d client_id=$DEC_USER_KEY -d client_secret=$DEC_USER_SECRET -d scope=write -X POST https://chats.go-data.at/oauth/token | jq -r '.access_token'`
  
# create collection
echo '{
  "name": "DEC112 Chat Repository",
  "meta": {"VerifiblePresentation-D2A": "https://chats.go-data.at/presentations/zQmVhfhW6mAs1dh3mhA2xSqdficgjni66Ke2XJNB4R4uVm9"}}' | \
curl -H "Authorization: Bearer $DEC_USER_TOKEN" \
     -H "Content-Type: application/json" -d @- \
     -X POST https://chats.go-data.at/collection/
  
# or update existing collection
echo '{
  "name": "DEC112 Chat Repository",
  "meta": {"VerifiblePresentation-D2A": "https://chats.go-data.at/presentations/zQmWf6zuSQY3dZFFppec4TkFxd6HT5p8T4PVVQyvcKWLgJ5"}}' | \
curl -H "Authorization: Bearer $DEC_USER_TOKEN" \
     -H "Content-Type: application/json" -d @- \
     -X PUT https://chats.go-data.at/collection/5
```

</details>

<details><summary>Upload Data to Intermediary</summary> 
<ul>
  <li>Object-ID: 6<br>
    
    curl -H "Authorization: Bearer $DEC_USER_TOKEN" https://chats.go-data.at/object/6
    curl -H "Authorization: Bearer $DEC_USER_TOKEN" https://chats.go-data.at/object/6/meta
    curl -H "Authorization: Bearer $DEC_USER_TOKEN" https://chats.go-data.at/object/6/read

  </li>
  <li>Command line for upload:</li>
</ul>

```bash=
# create meta data object
echo '{"name":"dataset 2024-01-26", "collection-id":5}' | \
curl -H "Authorization: Bearer $DEC_USER_TOKEN" \
     -H "Content-Type: application/json" -d @- \
     -X POST https://chats.go-data.at/object/

# upload data
curl -H "Authorization: Bearer $DEC_TOKEN" \
     https://chatbot.staging.dec112.eu/api/data | \
curl -H "Authorization: Bearer $DEC_USER_TOKEN" \
     -H "Content-Type: application/json" -d @- \
     -X PUT https://chats.go-data.at/object/6/write

cat chat.json | \
curl -H "Authorization: Bearer $DEC_USER_TOKEN" \
     -H "Content-Type: application/json" -d @- \
     -X PUT https://chats.go-data.at/object/6/write
```

</details>

### 4 - Data User signs Data Agreement

<details><summary>MoI signs Data Agreement</summary> 
<ul>
  <li>MoI DID: <code>did:oyd:zQmf8mUhkN73Sgwjpn1RaShyQbgVfVbGu8yYDzW7e8WGt2z</code></li>
  <li>MoI Private Key Password: <code>moipwd</code></li>
  <li>Command line to sign Data Agreement by MoI:</li>
</ul>

```bash=
cat d3a.json | \
oydid vc-proof --doc-pwd moipwd \
    --issuer did:oyd:zQmf8mUhkN73Sgwjpn1RaShyQbgVfVbGu8yYDzW7e8WGt2z \
    > d3a_MoI-signed.json
```

</details>

<details><summary>Data Intermediary signs Data Agreement</summary> 
<ul>
  <li>Intermediary DID: <code>did:oyd:zQmWwtUAbJHtd2wRU5GnR3wYWrt7vBQQ7U1GPK12tEvvKtU</code></li>
  <li>Intermediary Private Key Password: <code>oydpwd</code></li>
  <li>Command line to sign Data Agreement by OwnYourData:</li>
</ul>

```bash=
cat d3a.json | \
oydid vc-proof --doc-pwd oydpwd \
    --issuer did:oyd:zQmWwtUAbJHtd2wRU5GnR3wYWrt7vBQQ7U1GPK12tEvvKtU \
    > d3a_OYD-signed.json
```

</details>

<details><summary>Compile and Store Verifiable Credential for Data Agreement</summary> 
<ul>
  <li>MoI DID: <code>did:oyd:zQmf8mUhkN73Sgwjpn1RaShyQbgVfVbGu8yYDzW7e8WGt2z</code></li>
  <li>Intermediary DID: <code>did:oyd:zQmWwtUAbJHtd2wRU5GnR3wYWrt7vBQQ7U1GPK12tEvvKtU</code></li>
  <li>Intermediary Private Key Password: <code>oydpwd</code></li>
  <li>Verifiable Credential Address: <code>zQmYXL4xdDkEjiDrLF6UoZzf2BxAFjJgRQ2nUmmpdqLi1Pt</code></li>
  <li>Verifiable Presentation: <a href="https://chats.go-data.at/presentations/zQmVGSoLocMwJ1fE6hS3QkrVHZgQC4uuVMnvXwY4raG75Dr"><code>zQmVGSoLocMwJ1fE6hS3QkrVHZgQC4uuVMnvXwY4raG75Dr</code></a></li>
  <li>Command line to create VC & VP:</li>
</ul>

```bash=
cat d3a.json | \
jq --slurpfile sig1 d3a_MoI-signed.json \
   --slurpfile sig2 d3a_OYD-signed.json '{
    "credentialSubject": .,
    "proof": [$sig1, $sig2]}' | \
jq '. * {"credentialSubject": {"id":"did:oyd:zQmf8mUhkN73Sgwjpn1RaShyQbgVfVbGu8yYDzW7e8WGt2z"}}' | \
oydid vc-push --doc-pwd oydpwd \
    --issuer did:oyd:zQmWwtUAbJHtd2wRU5GnR3wYWrt7vBQQ7U1GPK12tEvvKtU \
    --holder did:oyd:zQmf8mUhkN73Sgwjpn1RaShyQbgVfVbGu8yYDzW7e8WGt2z \
    --location https://chats.go-data.at

# create VP
oydid vc-read zQmYXL4xdDkEjiDrLF6UoZzf2BxAFjJgRQ2nUmmpdqLi1Pt \
    --holder did:oyd:zQmf8mUhkN73Sgwjpn1RaShyQbgVfVbGu8yYDzW7e8WGt2z \
    --doc-pwd moipwd --location https://chats.go-data.at | \
oydid vp-push --doc-pwd oydpwd \
    --holder did:oyd:zQmf8mUhkN73Sgwjpn1RaShyQbgVfVbGu8yYDzW7e8WGt2z \
    --location https://chats.go-data.at
```

</details>

<details><summary>Register Access to Data Repository</summary> 
  
<ul>
  <li>Collection-ID: 5</li>
  
    curl -H "Authorization: Bearer $MOI_USER_TOKEN" https://chats.go-data.at/collection/5
    curl -H "Authorization: Bearer $IM_TOKEN" https://chats.go-data.at/collection/5/access

  
  <li>Command line to register access:</li>
</ul>

```bash=
# credential for MoI user
export MOI_USER_KEY="qhLTLMCBLZEQrDXZwxgpXNnyrBZ2Ack3lhUa5rZLilE"
export MOI_USER_SECRET="bPZGC-8oSpgpElTIIxPqCHJX19d0-uNy-RMduyadPGc"
export MOI_USER_TOKEN=`curl -s -d grant_type=client_credentials -d client_id=$MOI_USER_KEY -d client_secret=$MOI_USER_SECRET -d scope=write -X POST https://chats.go-data.at/oauth/token | jq -r '.access_token'`
  
# credential Intermediary Admin
export IM_KEY="Z9FITOpfGHb30A9siyiGgcAwv8IQ34vqWDhW5cABhh8"
export IM_SECRET="Kpg0pvIC-FvR3OWpUZo1egAwJVPKzGNdaEB_4yYKsEI"
export IM_TOKEN=`curl -s -d grant_type=client_credentials -d client_id=$IM_KEY -d client_secret=$IM_SECRET -d scope=admin -X POST https://chats.go-data.at/oauth/token | jq -r '.access_token'`

# register access
echo '{"VerifiablePresentation-D3A": "https://chats.go-data.at/presentations/zQmVGSoLocMwJ1fE6hS3QkrVHZgQC4uuVMnvXwY4raG75Dr"}' |
curl -H "Authorization: Bearer $MOI_USER_TOKEN" \
     -H "Content-Type: application/json" -d @- \
     -X POST https://chats.go-data.at/collection/5/access
  
# manually invoke Data Agreement check
jq -s '{"data-subject": .[0], "data-controller": .[1]}' \
<(curl -s https://chats.go-data.at/presentations/zQmbAJWhqBTb32xqnotUyGcTuMuXNxFjaeCapBT7RHVMqfV | jq "$(cat up_query.jq)") \
<(curl -s https://chats.go-data.at/presentations/zQmVGSoLocMwJ1fE6hS3QkrVHZgQC4uuVMnvXwY4raG75Dr | jq "$(cat up_query.jq)") | \
curl -s -o /dev/null -w "%{http_code}" \
     -H "Content-Type: application/json" -d @- \
     -X POST https://scdv-matching-oc3.data-container.net/api/validate/usagepolicy
```

</details>

### 5 - Data User retrieves data from Data Intermediary

<details><summary>Download Data from Intermediary</summary> 
<ul>
  <li>Object-ID: 6</li>
  <li>Command line for download:</li>
</ul>

```bash=
# credential for MoI user
export MOI_USER_KEY="qhLTLMCBLZEQrDXZwxgpXNnyrBZ2Ack3lhUa5rZLilE"
export MOI_USER_SECRET="bPZGC-8oSpgpElTIIxPqCHJX19d0-uNy-RMduyadPGc"
export MOI_USER_TOKEN=`curl -s -d grant_type=client_credentials -d client_id=$MOI_USER_KEY -d client_secret=$MOI_USER_SECRET -d scope=write -X POST https://chats.go-data.at/oauth/token | jq -r '.access_token'`

# download data
curl -s -H "Authorization: Bearer $MOI_USER_TOKEN" \
    https://chats.go-data.at/object/6/read \
    > raw_data.json

# show events
curl -s -H "Authorization: Bearer $DEC_USER_TOKEN" \
    https://chats.go-data.at/collection/5/events
```

</details>
