DevNet Associate DEVASC 200-901 Official Certification Guide by Adrian Iliesiu (z-lib.org)

(andrew) #1

You can use the Messages API to add a new member to a
given room (that is, create a new membership). To do so,
you use the POST method and the


API https://webexapis.com/v1/messages.


You can use a Python request to make a REST call.
Example 10-6 shows a curl script that sends a POST
message to add a new message to a particular room.


Example 10-6 Python Script to Add a New Message to
a Room


Click here to view code image


""" Send Webex Message """
import json
import requests
import pprint
URL = "https://webexapis.com/v1/messages"
PAYLOAD = {
"roomId" :
"Y2lzY29zcGFyazovL3VzL1JPT00vY2FhMzJiYTAtNTA0OC0xMWVhLWJiZ-
WItYmY1MWQyNGRmMTU0",
"text" : "This is a test message"
}
HEADERS = {
"Authorization": "Bearer
NDkzODZkZDUtZDExNC00ODM5LTk0YmYtZmY4NDI0ZTE5ZDA1MGI-
5YTY3OWUtZGYy_PF84_consumer",
"Content-Type": "application/json",
}
RESPONSE = requests.request("POST", URL,
data=json.dumps(PAYLOAD), headers=HEADERS)
pprint.pprint(json.loads(RESPONSE.text))

Bots


A bot (short for chatbot) is a piece of code or an
application that simulates a human conversation. Users
communicate with a bot via the chat interface or by
voice, just as they would talk to a real person. Bots help

Free download pdf