How To: Using Integration Tokens with Questionnaires
Welcome to the Semble GraphQL API how-to guide. In this guide, we will walk you through the process of using integration tokens with questionnaires to directly match a patient, eliminating the need for patients to re-enter their details every time.
Here are the steps:
Step 1: Authenticate
Before making any requests, make sure you have a valid token. Refer to the Authentication section for more details.
Step 2: Create an Integration Token
To create an integration token, you will need to use the createIntegrationToken
mutation.
Integration tokens are valid for one week, here's how to create one in different languages:
- curl
- Javascript
- Python
curl -X POST https://open.semble.io/graphql \
-H "Content-Type: application/json" \
-H "x-token: yourtoken" \
-d '{
"query": "mutation { createIntegrationToken { id } }"
}'
const fetch = require('node-fetch');
const query = `
mutation {
createIntegrationToken {
id
}
}
`;
fetch('https://open.semble.io/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-token': 'yourtoken',
},
body: JSON.stringify({ query }),
})
.then((res) => res.json())
.then((res) => console.log(res.data));
import requests
import json
query = """
mutation {
createIntegrationToken {
id
}
}
"""
headers = {
'Content-Type': 'application/json',
'x-token': 'yourtoken',
}
response = requests.post(
'https://open.semble.io/graphql',
headers=headers,
data=json.dumps({"query": query})
)
print(response.json())
Step 3: Get Integration Token
To retrieve the integration tokens, use the integrationToken
query. Here's how:
- curl
- Javascript
- Python
curl -X POST https://open.semble.io/graphql \
-H "Content-Type: application/json" \
-H "x-token: yourtoken" \
-d '{
"query": "query { integrationToken { id } }"
}'
const fetch = require('node-fetch');
const query = `
query {
integrationToken {
id
}
}
`;
fetch('https://open.semble.io/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-token': 'yourtoken',
},
body: JSON.stringify({ query }),
})
.then((res) => res.json())
.then((res) => console.log(res.data));
import requests
import json
query = """
query {
integrationToken {
id
}
}
"""
headers = {
'Content-Type': 'application/json',
'x-token': 'yourtoken',
}
response = requests.post(
'https://open.semble.io/graphql',
headers=headers,
data=json.dumps({"query": query})
)
print(response.json())
Step 4: Append the Integration Token to the Questionnaire URL
Once you have the integration token, you can append it to a questionnaire URL like so:
https://questionnaires.semble.io/:questionnaireToken/:integrationToken
Where:
:questionnaireToken
is the token of the questionnaire you want the patient to fill.:integrationToken
is the token you obtained in the previous steps.
This URL will take the patient directly to the questionnaire without needing to enter their details each time.
Conclusion
Congratulations! You've successfully used integration tokens with questionnaires in the Semble API. This will streamline your patients' experience and improve the efficiency of data collection in your application. Happy integrating!