-
Notifications
You must be signed in to change notification settings - Fork 5
/
send_event.py
42 lines (35 loc) · 982 Bytes
/
send_event.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import requests
import uuid
import time
import datetime
url = "https://api.amazonalexa.com/v3/events"
skill_token = 'Atza|xxxxxxx'
customer_token = 'Atza|zzzzzzzzzzz'
headers = {'Authorization' : 'Bearer '+customer_token}
payload = {
"context": {},
"event": {
"header": {
"messageId": str(uuid.uuid4()),
"namespace" : "Alexa.DoorbellEventSource",
"name": "DoorbellPress",
"payloadVersion": "3"
},
"endpoint": {
"scope": {
"type": "BearerToken",
"token": customer_token
},
"endpointId": "browser-001"
},
"payload" : {
"cause": {
"type": "PHYSICAL_INTERACTION"
},
"timestamp": datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%dT%H:%M:%S.%fZ')
}
}
}
print(payload)
resp = requests.post(url, headers=headers, json=payload)
print(resp)