# BoostMate x CoSpace integration
## Intro
[Link](https://t.me/boost_mate_bot) to BoostMate bot. The only command you need is `/add_group`. The other commands are not suitable for this integration.
## Events auto-creation in BoostMate when approved on CoSpace side
Once CoSpace manager approves any event **you should send POST-request** with JSON-body containing the following params:
```
{
"userId": "telegram_user_id of CoSpace events manager",
"name": "name of an event",
"description": "HTML-styled string describing the event. You can set here price, time and contacts using HTML tags like <b>Time: ...</b>",
"imageUrl": "Link to event cover image",
"chatIds": "Array of numbers representing telegram chat ids",
"externalCampaignId": "CoSpace event-id",
"startMethod": "Should be set as immediately",
"finishMethod": "Should be set as scheduled",
"finishesAt": "Should be set with event end date in ISO8601 format"
}
```
Endpoint where to send request: `https://boostmate.ru/api/v1.0/campaigns/co-space`
Example of request:
```
curl --location 'https://boostmate.ru/api/v1.0/campaigns/co-space' \
--header 'Content-Type: application/json' \
--data '{
"userId": 5899470103,
"name": "Тестовый ивент через API",
"description": "Здесь будет <b>описание</b> ивента. <b>Цена</b>: 150TL",
"imageUrl": "https://res.cloudinary.com/glide/image/fetch/f_auto,w_500,c_limit/https%3A%2F%2Fstorage.googleapis.com%2Fglide-prod.appspot.com%2Fuploads-v2%2Fhdx4KxbN5bT22omps9bi%2Fpub%2F1wS120hE5fKEle2LTrh2.jpeg",
"chatIds": [
-1001874750085
],
"externalCampaignId": "PwwZWfdJTR-QNyOYX0RvQQ",
"startMethod": "immediately",
"finishMethod": "scheduled",
"finishesAt": "2023-05-22T18:00:00Z"
}'
```
**Warning!**
Before sending this request manager of the CoSpace events should authorize their telegram chat in BoostMate bot via the command `/add_group` in the [bot](https://t.me/boost_mate_bot)
Once the manager send this command such message should be received:

Click to the button and give the bot all necessary rights
## Register for the event
### via bot
Once a user clicks on button "Register" in the bot

BoostMate sends POST-request with JSON-body like that:

The request are sent to Make endpoint: `https://hook.eu1.make.com/acz9t1hcxse9dwq02asovi1f8l1pslp3`
**You should receive and operate this request**
*Warning! We have already agreed this flow!*
### via button on CoSpace site

**You should add a button** (might be like it is above) to the Event registration sidebar. By clicking the button user must be redirected to the URL like "https://t.me/boost_mate_bot?start=pl_co-space_<HERE_CO_SPACE_EVENT_ID>"
An example page of how it could work: https://codesandbox.io/s/co-space-register-for-the-event-button-idoeww
## Testing
Totally, we have the following steps in our test-plan (once all development tasks are done):
- Create an event on CoSpace site
- Approve the event by manager
- BoostMate should create event and publish a post with given params
- Afterthat you can test both registration flows as well as the invitation flow