Skip to content

Instantly share code, notes, and snippets.

@ZackStone
Created August 9, 2017 00:56
Show Gist options
  • Save ZackStone/07f119527009dc7d70bc5420b4588f0a to your computer and use it in GitHub Desktop.
Save ZackStone/07f119527009dc7d70bc5420b4588f0a to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 8 21:21:59 2017
@author: yitzhak
"""
# pip install --upgrade watson-developer-cloud
from watson_developer_cloud import ConversationV1
conversation = ConversationV1(
username='username',
password='pass',
version='2017-05-26'
)
import http.client
conn = http.client.HTTPSConnection("gateway.watsonplatform.net")
# generate headers in postman
headers = {
'authorization': "",
'cache-control': "no-cache",
'postman-token': ""
}
conn.request("GET", "/conversation/api/v1/workspaces?version=2017-05-26", headers=headers)
res = conn.getresponse()
data = res.read()
# get workspace id
#print(data.decode("utf-8"))
workspace_id = 'id'
context = {}
import json
response = conversation.message(
workspace_id=workspace_id,
message_input={'text': 'Hello Watson!'},
context=context
)
print(json.dumps(response, indent=2, ensure_ascii=False))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment